Google recently published experimental support for running junit on a local JVM in Android Studio. I wanted to try, and since I am developing an Android application using Kotlin, I want my test classes to be written in Kotlin.
Unfortunately, I cannot get it to work. I updated the gradle configuration:
sourceSets { main.java.srcDirs += 'src/main/kotlin' androidTest.java.srcDirs += 'src/androidTest/kotlin' test.java.srcDirs += 'src/test/kotlin'//this line was added } testCompile 'junit:junit:4.12' testCompile "org.mockito:mockito-core:1.9.5"
Android Studio recognizes the test folder.
This is my simple test class to see if it works
public class MyFirstTestClass { [Test] fun firstTest() { println("I am OK") Assert.assertTrue("".isEmpty()) } }
If I try to run it, I get the following message
Class not found: 'com.example.MyFirstTestClass'
source share