I'm poking around with Kotlin, but I don't actually know how to run unit tests. I see some outdated examples on writing tests, but I don't know how to run them. I'd like to learn how both for JVM and JavaScript projects.
In a Java project with IntelliJ if I have junit on my classpath I can press ctrl+shift+T to automatically create a test case, but in Kotlin I don’t seem to be able to do that.
Test fun helloTest(): Unit {
val h = HelloKotlin();
var hello = h.helloKotlin();
assertEquals(“hello”, hello);
}
}
I haven’t figured it out for javascript yet, I don’t know what library I need to import for javascript.
I get the runtime error:
java.lang.NoClassDefFoundError: junit/textui/ResultPrinter
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)
at java.lang.Class.getMethod0(Class.java:2764)
at java.lang.Class.getMethod(Class.java:1653)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)