3
votes

I have a project in Android Studio where I created a java library module. In there I have a Kotlin class which I want to test. When I create the test in Kotlin and try to run it, the IDE keeps telling me:

Process finished with exit code 1 Class not found: "com.example.CacheTest" Empty test suite.

When I create the same test in Java everything works fine.

I created tests in other projects in Kotlin as well and there it works.

I recently update AS to 2.2.2 and use Kotlin 1.0.4

Does anyone have any suggestions?

1

1 Answers

1
votes

Do you have this in your build.gradle?

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
    test.java.srcDirs += 'src/test/kotlin'
}

dependencies {
    testCompile 'junit:junit:4.12'
}

Directory structure like:

enter image description here

and a test class:

import org.junit.Assert
import org.junit.Test

class TestCase {

    @Test fun someTest(){
        Assert.assertFalse(true)
    }
}