I want to define unit tests for my classes and am running into the following issue. If I define the unit test inside the androidTest folder (testing with instrumentation) then the test runs normally with valid results. If, however, I define the test inside the test folder (local testing) then running the test generates a message "class not found: "[classname]" Empty test suite". This wouldn't be so bad and I would just run all tests from androidTest, except that I want to use code coverage and Android Studio doesn't allow me to run coverage tests from androidTest, but only from test.
Why isn't Android Studio able to find the unit tests when they are defined in the test folder, but is able to when they are defined in the androidTest folder?
Code:
public class SomeTest{
private Context mInstrumentationCtx;
@Before
public void setup() {
mInstrumentationCtx = InstrumentationRegistry.getTargetContext();
// do some setup actions
}
@Test
public void testFirst() throws Exception {
Assert.assertEquals(true, true);
}
}
Gradle config:
android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
debug {
testCoverageEnabled = true
}
}
testCompile 'junit:junit:4.12'
testCompile ('com.android.support.test:runner:0.5', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'