Reputation: 5486
I've run into very strange error.
When i try to run test that are in my Kotlin class in androidTest package they are running as test junit mehthods and this error appears:
Process finished with exit code 1 Class not found: "com.someampp.shoppinglistapp.SomeClassTest"Empty test suite.
You can try it for yourself. I am using Android Studio 3.0.1
When i am creating class like this in Java:
@RunWith(AndroidJUnit4.class)
public class SomeTestClass{
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.myapp.shoppinglistapp", appContext.getPackageName());
}
}
Everything works fine.
But when i convert the Java file to Kotlin:
@RunWith(AndroidJUnit4::class)
class SomeTestClass{
@Test
@Throws(Exception::class)
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getTargetContext()
assertEquals("com.myapp.shoppinglistapp", appContext.packageName)
}
}
It gives me this error.
Whats wrong?
Upvotes: 1
Views: 742
Reputation: 170713
You need to open Run/Debug configurations
and create one for Android Instrumented Tests instead of Android JUnit.
Upvotes: 2