Why do I need kotest-framework-engine in the main sourceSets?

74 views Asked by At

Through trial and error I've managed to setup kotest for a Kotlin Multiplatform desktop application, but I'm not quite sure I know what I'm doing. I thought that I need the test dependencies only in the test sourceSets, but when I don't include at least the kotest-framework-engine also in the main, the tests won't compile. Is this configuration as it should be or am I doing something wrong?

My build.gradle.kts looks like this:

kotlin {
    sourceSets {
        val main by getting {
            dependencies {
                // https://mvnrepository.com/artifact/io.kotest/kotest-framework-engine-jvm
                implementation("io.kotest:kotest-framework-engine-jvm:5.8.0")
            }
        }
        val test by getting {
            dependencies {
                // https://mvnrepository.com/artifact/io.kotest/kotest-framework-engine-jvm
                implementation("io.kotest:kotest-framework-engine-jvm:5.8.0")

                // https://mvnrepository.com/artifact/io.kotest/kotest-runner-junit5-jvm
                implementation("io.kotest:kotest-runner-junit5-jvm:5.8.0")

                // https://mvnrepository.com/artifact/io.kotest/kotest-assertions-core
                implementation("io.kotest:kotest-assertions-core:5.8.0")
            }
        }
    }
}

and the project structure is:

my-project
   \src
      \main
         \kotlin
             \...
   \src
      \test
         \kotlin
             \test1.kts

where test1.kts is

import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe

class Test1 : FunSpec ({
    test("is this a number") {
        "2".toFloatOrNull() shouldBe 2.5f
    }
})
0

There are 0 answers