Unit Tests

13
Jun

Difference between unit tests and instrumentation tests

Difference Between Unit Tests and Instrumentation Tests


 Android Studio allows you to write unit test as well as instrumentation tests. It is very important for us to learn more about unit tests and instrumentation tests. We have defined it in terms of Android Application.

In layman terms, Unit tests are the test cases written for testing code written by developers and Instrumentation test are the test cases written for testing UI & functionality of the application. In short, Unit tests is associated with white box testing and instrumentation tests is associated with black box testing.

Unit Tests –

  • Unit tests runs in local JVM and minimizes the execution time.
  • Unit Tests cannot test UI of the app without mocking activity objects.
  • Unit test are used for white box testing for testing code.
  • Most of the time Unit Tests are written by Developers.
  • You don’t need a device connected for execution of Unit Tests.

Instrumentation Tests –

  • Instrumentation tests are used for black box testing.
  • It is used to test GUI of the application along with its functionality in real environment.
  • For execution of Instrumentation tests you need a device /emulator on which the application is first installed and then tests are executed.
  • Automation Testers are involved in writing instrumentation framework.