Hi, just new to Kotlin but I wanted to see if I can integrate it with my test project. I tried to follow the instructions in Using Maven and created a simple JUnit file like based on the example. I am using 1.1.2-3
I have two issues:
When I ran it on Maven I got the following error
[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.1.2-3:test-compile (test-compile) on project jee-domain: Compilation failure
[ERROR] D:\p\jee\jee-domain\src\test\kotlin\net\trajano\jee\domain\kotlin\test\KotlinSanityTest.kt:[7,3] Cannot access class ‘kotlin.reflect.KClass’. Check your module classpath for missing or conflicting dependencies
On Eclipse it does not automatically register src/main/kotlin and src/test/kotlin as a source folder.
The app I have is
The changes are small to add the kotlin support as specified by Using Maven
AFAIK, dependencyManagement block is used to specify versions of your dependencies, but not to add them automatically to the classpath. So you need to specify kotlin-stdlib also (or solely) in project/dependencies block.
Nope that didn’t work. when I try to execute the JUnit for Kotlin in src/test/java I don’t see it when I try to execute on the src/test/java It runs when I do the specific test though. The good part is it works on the maven build line, just not on the Eclipse.
It’s ok to place kotlin files in java source directory.
For running tests written in kotlin you may need this additional configuration of surefire plugin to find not only tests with .java extension:
I guess the only issue left is doing a test executions in Eclipse from the package or directory level. Hopefully a new version of the Kotlin Eclipse plugin (I think) can handle that.
But those will define a new launch, I don’t really see an extension point to JUnit itself, To change how it calculates the suites. EclEmma may have some code for that.