Is there a way to only run a specific set of tests in an Android Gradle project? -
i have android/gradle project. whenever want run tests, run:
./gradlew connectedinstrumenttest
which runs tests under test folder of project.
my test folder has several automation tests non-automation tests. i'm interested in running fast non-automation tests without slow automation tests.
is there way run specific set of tests, such 1 specific class or similar? i'm asking kind of separation can choose run few tests when want to.
created sample project here.
edit local.properties
point @ android sdk.
next, start emulator or connect phone computer. can run tests using ./gradlew connectedinstrumenttest --info
. runs tests.
what unable figure out how run tests in, say, 1 class , not tests.
since android gradle plugin 1.3.0
starting version 1.3.0 can (finally!) specify arguments android gradle plugin have pass instrumentationtestrunner
.
for example, if want run tests annotated @smalltest
, ignore others:
android { //.... defaultconfig { //.... testinstrumentationrunner "android.support.test.runner.androidjunitrunner" testinstrumentationrunnerargument "size", "small" } }
old workaround prior plugin 1.3.0 not possible i've found little workaound. i've annotated @smalltest
annotation fast tests , using custom subclass of instrumentationtestrunner
i'm able run them , not whole suite.
you can found example code in this gist.
Comments
Post a Comment