I have two different types of instrumentation tests for my Android app, each of which require different instrumentation test runner classes.
I have been unable to find a clean way of encapsulating these test runners into a single class, and am now looking to separate these tests into two suites each with its own instrumentation test runner.
Is it possible to create another test folder alongside androidTest
, and how can this be configured within my build.gradle
?
Create a new folder on the same level as test
and androidTest
(e.g.: I created one called acceptanceTest
).
Then, in your module's build.gradle file include this outside the android { }
block:
android.sourceSets {
androidTest {
java.srcDirs += "$projectDir/src/acceptanceTest"
}
}
Now you will be able to run instrumented tests on this new folder too.
PS.: If you want a folder accessible by both androidTest
and test
folders (say, a test fixtures folder called testShared
), do the same process but also include a test { }
block there:
android.sourceSets {
test {
java.srcDirs += "$projectDir/src/testShared"
}
androidTest {
java.srcDirs += "$projectDir/src/testShared"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With