Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle: How to run instrumentation test for class

I'm running instrumentation test in Android Studio with Run Configuration defined as below (don't mind warning): enter image description here

So this is invoking test suit for a specific class. How can I achieve this with command line, I guess using ./gradlew command ?

like image 300
Adam Styrc Avatar asked Sep 16 '15 08:09

Adam Styrc


People also ask

How can you run tests in Gradle?

Run Gradle testsIn your Gradle project, in the editor, create or select a test to run. From the context menu, select Run <test name>. icon in the left gutter. If you selected the Choose per test option, IntelliJ IDEA displays both Gradle and JUnit test runners for each test in the editor.

What is an instrumentation test?

In summary, an instrumentation test provides a special test execution environment as launched via the am instrument command, where the targeted application process is restarted and initialized with basic application context, and an instrumentation thread is started inside the application process VM.


1 Answers

As stated in the AndroidTestingBlueprint you can use the android.testInstrumentationRunnerArguments.class property:

./gradlew app:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.example.android.testing.blueprint.ui.espresso.EspressoTest 
like image 155
rciovati Avatar answered Sep 28 '22 07:09

rciovati