Friday 1 April 2016

Android Unit Testing

The Gradle Plugin supports two different types of tests.

Unit Testing is supported by locating all classes under the path src/test/java and any dependencies defined within the module gradle build file e.g. testCompile based dependencies.

Instrumented Tests covers all tests that are intended to be run against the app within the emulator or live device. These test classes by default are located under src/androidTest/java and have corresponding module dependencies e.g. testAndroidCompile

Unit tests can be run in one of two ways depending on context.

Command Line from the command line, the Gradle task test can be used to run and generate a report of the test results.

bash gradlew test; open app/build/reports/tests/debug/index.html

From the IDE from within IntelliJ or Android Studio the unit tests can be run by:

  • Select "Build Variants" from left tray
  • Select Test Artifact = Unit Tests
  • Run indiviual or groups of tests as usual

.

No comments:

Post a Comment