How do you run unit tests?

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.


I figured it out for Kotlin in the JVM:

  1. add junit as a maven dependency
  2. add the import:  import org.junit.Test

    import kotlin.test.assertEquals
    import org.junit.Test

public class HelloTest {

     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(
     at java.lang.Class.getMethod0(
     at java.lang.Class.getMethod(
     at sun.launcher.LauncherHelper.getMainMethod(
     at sun.launcher.LauncherHelper.checkAndLoadMain(

Could You please share your project?

For posterity, my questions were answered in the other thread: