Running tests
We already executed our tests through the Android Studio. However, once you write them all, you will want to run them all at once. You can run all the unit tests for all build variants, but only for a certain flavor or build type. The same applies for instrumentation tests. We will show you several examples to do so using existing build variants for the Journaler
application.
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...