Running unit tests

Open the terminal and navigate to the root package of the project. To run all unit tests, execute the following command line:

$ ./gtradlew test

This will run all the unit tests we wrote. The testing will fail since NoteTest uses content provider. For this, it's required to be executed with the proper Runner class. Android Studio, by default, does that. However, since this is a unit test, and we execute it from the terminal, testing will fail. You will agree that this test is actually something that has to be considered as instrumentation since it uses the Android Framework components. Common practice is that if your class relies on the Android Framework components, it has to be executed as instrumentation. Because of this, ...

Get Mastering Android Development with Kotlin now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.