Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

command line arguments to Android instrument test using gradle

Does anyone has an idea about how to pass command line arguments to Android instrumentation tests run using gradle. Calling gradle connectedInstrumentTest with -p arguments or -D arguments did n't seem to work .I am trying to pass command line arguments to my instrument test using gradle.

like image 844
Jayesh Muralidharan Avatar asked Jul 22 '13 20:07

Jayesh Muralidharan


People also ask

How do you run a test case using Gradle command?

You can do gradle -Dtest. single=ClassUnderTestTest test if you want to test single class or use regexp like gradle -Dtest. single=ClassName*Test test you can find more examples of filtering classes for tests under this link.

How do I use Android instrumentation test?

In order to run the instrumentation test, you need to select Android Instrumentation Tests under Test Artifact in the Build Variants window. You should see the project structure change and the classes under the androidTest folder should now be visible.

Which command lets you generate the unit tests of a project developed with Gradle?

We can run our unit tests by using the command: gradle clean test.


2 Answers

It is possible since 1.3.0 version of plugin according to docs: http://tools.android.com/tech-docs/new-build-system

It's now possible to specify instrumentation test runner arguments in build.gradle (in defaultConfig or per flavor):

android {
     defaultConfig {
         testInstrumentationRunnerArguments size: "medium"
     } 
 }

This can also be done on the command line:

./gradlew cC -Pandroid.testInstrumentationRunnerArguments.size=medium

like image 184
Aleksei Potapkin Avatar answered Oct 08 '22 21:10

Aleksei Potapkin


you mean pass arguments to the am command? It's not possible at the moment.

like image 36
Xavier Ducrohet Avatar answered Oct 08 '22 20:10

Xavier Ducrohet