Is there a way to run a specific Android instrumentation unit test using Gradle? I\'ve tried
gradle -Dtest.single=UnitTestName connectedInstrumentTest
This works if you're using an instrumentationTestRunner
:
./gradlew test -Pandroid.testInstrumentationRunnerArguments.class=.YourClassName
Using gradle 2.10 and android gradle plugin 2.0.0-beta2.
Since you know what test(s) you want to run, you probably know which module / flavor to use too. You can help Gradle out by specifying the exact module and Gradle task. So if your test is in the app
module and you want to test the debug
flavor:
./gradlew app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=.YourClassName
You can get even more fancy with the tests_regex
argument instead:
./gradlew app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.tests_regex=PartialClassName*
./gradlew app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.tests_regex=partialMethodName*