https://kotlinlang.org logo
#kotest
Title
# kotest
v

Vishnu Shrikar

11/10/2023, 8:50 AM
So jetbrain's super amazing kmp plugin includes absolutely zero test setup. Include tests so that all developers can be encouraged to write well made code? Jetbrains would rather just give you a ktor server. This means I have to try and set up kotest on my own without a common test. It does not seem to work so I am reaching out for some help. Let me show you what I did first I added this in the build.gradle in the sourceSets section
Copy code
val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
                implementation("io.kotest:kotest-assertions-core:${project.property("kotest-assertions-version")}")
                implementation("io.kotest:kotest-framework-engine:${project.property("kotest-assertions-version")}")
            }
        }
I then created the commonTest directory under the src folder so it looks like the included image. I also created a class called DatabaseTest. Then I wrote this test
Copy code
class DatabaseTest : FreeSpec() {

    init {

        "test" {
            0 shouldBe 0
            fail("ssp")
        }


    }


}
Doing ./gradlew test shows successful which means its not running the test. Running the test through the kotest plugin gives me this error
Copy code
Cannot locate tasks that match ':composeApp:compileJava' as task 'compileJava' is ambiguous in project ':composeApp'. Candidates are: 'compileDebugAndroidTestJavaWithJavac', 'compileDebugJavaWithJavac', 'compileDebugUnitTestJavaWithJavac', 'compileReleaseJavaWithJavac', 'compileReleaseUnitTestJavaWithJavac'.
Any clue on how to solve this annoyance?
d

Distractic

11/10/2023, 10:22 AM
For JVM, you need to import
io.kotest:kotest-runner-junit5:$version
in JvmTest module
Copy code
val jvmTest by getting {
            dependencies {
                implementation("io.kotest:kotest-runner-junit5:$version")
            }
        }
$version
is the kotest version of course
v

Vishnu Shrikar

11/10/2023, 4:06 PM
do i need to import different things per platform?
d

Distractic

11/10/2023, 4:06 PM
just for JVM
For Common & Native, the dependencies in commonTest added are enough
v

Vishnu Shrikar

11/10/2023, 4:07 PM
What about android
d

Distractic

11/10/2023, 4:07 PM
hum .. probably same than JVM
v

Vishnu Shrikar

11/10/2023, 4:07 PM
Ok ill try that after work today thanks
I still have the same problems and I think i got the dependancies sorted. It may be Intellij being weird thought intellij seldom does this type of stuff
4 Views