Experimental JUnit support in Android + Kotlin not working
android, junit, kotlin
Solution
Unfortunatly, kotlin-gradle plugin doesn't support Junit tests for Android at this moment.
EDIT: Junit support for android was added in Kotlin M12
Problem
Google recently released experimental support for running junit on local JVM in Android Studio. I wanted to try it out and since I am developing my Android app using Kotlin I want my tests classes be written in Kotlin too. Unfortunately, I can't make it working. I have updated my 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 recognise test folder. This is my simple test class just 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'