Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute Espresso multiple test classes separately using gradlew command

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
like image 932
RosAng Avatar asked Mar 01 '26 23:03

RosAng


1 Answers

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
like image 103
dweebo Avatar answered Mar 05 '26 00:03

dweebo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!