Kotlin 101: Howto Unit testing in Kotlin? no available resounce like io

[Just to give a n00b context, Im beginning to setup a full fledged dev project environment in InteliJ. And this is my 1st query.]

When I setup a unit test in a project module package, kotline imports a bunch of testing libraries there starting with io.kotlin... like this:

//import groovy.lang.GroovyLogTestCase
//import groovy.transform.ASTTest
//import io.kotlintest.specs.StringSpec
//import io.kotlintest.specs.FunSpec
//import io.kotlintest.TestCase
//import io.kotlintest.TestResult
//import io.kotlintest.shouldBe
//import io.kotlintest.matchers.exactly
//import io.kotlintest.matchers.shouldBe
//import io.kotlintest.specs.FunSpec

but none of io.kotlintests could be found. Am I missing something in package.
I see JUnit5 is available in the project module settings as an available library.

Also, should I be following the vanilla io.kotlintest library.
Would also appreciate some starting resources/video on this. thanks.

You can use “gradle init” to create a fresh Kotlin project, there will be a auto generated code with JUnit 4

if you want JUnit 5 then you need to change the package names and add corresponding dependencies

You can use this example project JUnit 5 Example

So my inteliJ project provides JUnit5 library. You mean the packages that I see are JUnit4 packages? If I use JUnit5, I can remove those old imports right ? and do something like:

import org.junit.jupiter.api.Assertions.*

import org.junit.jupiter.api.Test


1 Like

great. thanks for clarifying. i guess intelij is taking junit4 by default. probably they will switch to junit5