3

I have Espresso instrumentaion test cases in following form in Android studio.

Screen from Android Studio

Now, I want to run few of the classes separately.

E.g : I want to run Only CrashersTest and EM3AppUtil classes using gradlew command and rest classes using another command.

How can i achieve it?

  • I am using below command

./gradlew :app:connectedLocalDebugAndroidTest

  • It runs all the classes for LocalDebug variant
  • I want to run only few classes
Bartek Lipinski
  • 30,698
  • 10
  • 94
  • 132
RosAng
  • 1,010
  • 2
  • 18
  • 42

2 Answers2

4

There isn't a great way to do it for instrumented tests right now that I know of.

You can create a test suite to run just certain test you want, like documented here https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests.html#test-suites

Or use the @SmallTest, @MediumTest or @LargeTest annotations on your tests and then pass in on command line like so

./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.size=small
dweebo
  • 3,222
  • 1
  • 17
  • 19
0

Place the cursor on the class name in java file or select the file in file view then press ctrl+shift+F10

Refer this How to run only one test class on gradle for running tests from gradlew command

Community
  • 1
  • 1
arjun
  • 3,514
  • 4
  • 27
  • 48
  • I see, but i dont see any way of filtering instrumentation test cases. This one is for the Junit test case. – RosAng Feb 28 '17 at 11:47