Oussaki
Oussaki

Reputation: 1649

Failing to run Instrumented tests on a new Android Kotlin project

I just created a new android application with Kotlin Support.

When I've tried to run the default instrumented tests it does not run and shows me this message:

Class not found: "oussaki.com.pos.ExampleInstrumentedTest"Empty test suite.

This the Instrumented test class that I'm trying to run:

@RunWith(AndroidJUnit4::class) 
class ExampleInstrumentedTest {
    @Test
    fun useAppContext() {
        // Context of the app under test.
        val appContext = InstrumentationRegistry.getTargetContext()
        assertEquals("oussaki.com.pos", appContext.packageName)
    }
}

enter image description here

Upvotes: 3

Views: 741

Answers (1)

Mateo
Mateo

Reputation: 559

This is a known issue: https://issuetracker.google.com/issues/38452937 which hopefully will be fixed in the next release.

For the time being you can manually go to 'Edit Configurations' and add the configuration for the specific class/method you want to run under 'Android Instrumented Tests'.

You could also try the latest canary build: https://developer.android.com/studio/preview/index.html but personally I've had trouble getting it to work with my project.

Upvotes: 3

Related Questions