I have a pure Java sub-project within my Android project. I already have a test suite located within src/test/java, and I wish to introduce a second test suite for integration tests.
I have specified this within my build.gradle as follows:
sourceSets {
integration {
java {
compileClasspath += test.compileClasspath
runtimeClasspath += test.runtimeClasspath
}
}
}
task integrationTest(type: Test, description: 'Runs the integration tests.', group: 'Verification') {
testClassesDir = sourceSets.integration.output.classesDir
classpath = sourceSets.integration.runtimeClasspath
}
configurations {
integrationCompile.extendsFrom testCompile
integrationRuntime.extendsFrom testRuntime
}
with tests located within src/integration/java. These tests can be run successfully from the command line, and within Android Studio, the java folder appears in green like the main test suite.
But when right-clicking and choosing "Run 'All Tests'", I get the errors No tests were found, Empty test suite..
How can I have a second test suite that can be run easily from within Android Studio?
You can try by using SuiteClasses. For example if you have multiple Test classes in a package you can create a Suite.class that is running the suites you want, even all tests as long as you specify them. Then right click and run test on that class. Here is example:
@RunWith(Suite.class)
@SuiteClasses({
EmailValidatorTest.class,
NewTest.class })
public class AllTests {
}
Example structure:

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