how to execute individual Junit test in android using gradle

28 views Asked by At

My project contains multiple test classes and each class contains some test methods. I can run all the test using command line

gradlew testDebugUnitTest

Is there any gradlew command to run specific testMethod from a class?
Is there any gradlew command to run all test mmethods from a specific class?
1

There are 1 answers

1
The_Martian On

Here is a class Foo2 and bar3 is the particular method you would like to test. This was taken from the Google developer Junit unit test command line documentation

$ adb shell am instrument -w \
> -e class com.android.demo.app.tests.Foo2#bar3 \
> com.android.demo.app.tests/android.support.test.runner.AndroidJUnitRunner