Reputation: 3543
Not a unit test, but an instrumentation test.
My app has multiple flavors, so I run:
./gradlew connectedClientDebugAndroidTest
to run my instrumentation tests (flavor name is client).
But I want to run one particular instrumentation test case class called MyActivityTestCase.java
. Is this possible? If it is what is the command to run this
Upvotes: 1
Views: 1910
Reputation: 3543
So the way I fixed this was by putting the single TestCase that I want into a specific folder by flavor.
app/src/androidTestClient/MyActivityTestCase.java
./gradlew connectedClientDebugAndroidTest
Not a solution if you have multiple test cases for a specific build flavor, but for me that wasn't the case so it works.
app/src/androidTestOther/
. So to run the other instrumentation tests I just run the command ./gradlew connectedOtherDebugAndroidTest
Upvotes: 0
Reputation: 83527
With Gradle, you can run a single test by using the test.single
system property. You set it from the command-line with the -D
option. For example
$ gradle -Dtest.single=MyActivityTestCase connectedClientDebugAndroidTest
For more details, see http://mrhaki.blogspot.com/2013/05/gradle-goodness-running-single-test.html.
Upvotes: 1
Reputation: 835
The general syntax using adb shell is :
adb shell am instrument -w <test_package_name>/<runner_class>
where is the Android package name of your test application, and is the name of the Android test runner class you are using.
More details at: http://developer.android.com/tools/testing/testing_otheride.html
Upvotes: 0