Running Android unit / instrumentation tests from the console
Unit tests
Here’s a few handy commands if you want to run only a specific unit test(s). Suppose we have the following unit tests in the project:
./gradlew test
– run unit tests for all variants
./gradlew testDebug
– run tests for Debug variant
./gradlew testDebug --tests="*.helpers.*"
– run all tests in the helpers
package
./gradlew testDebug --tests="*.HelperTest"
– run all tests in HelperTest.java
class
./gradlew testDebug --tests="*.getHelp"
– run only the getHelp
test method.
read more