Skip to main content
Version: 6.1 🚧

Setup

The Kotest test framework is supported on JVM, Javascript, Native and Wasm. To enable Kotest for multiple platforms, follow the steps for the platform you are targeting as detailed in the following tabs.

caution

The KMP support in Kotest 6.0 has changed from the previous versions. There is no longer a compiler plugin but a simplified setup. Please see the rest of this page for details on how to configure Kotest for KMP in Kotest 6.0 and later.

tip

When running the Gradle test task, Gradle will cache the output and report no tests executed if no source code has changed. See the section on rerunning tests for details on how to disable this behaviour.

tip

A working project with JVM support can be found here: https://github.com/kotest/kotest-examples

Kotest on the JVM has two ways for running tests. One uses the Kotest gradle plugin, which provides detailed test output in the console, and a rich experience in Intellij (in conjuction with the Intellij Kotest plugin). The other option uses the JUnit Platform gradle plugin which is ubiquitous in the JVM ecosystem but lacks some features of the Kotest gradle plugin.

To use the Kotest gradle plugin, add the following to your build.gradle.kts file:

plugins {
id("io.kotest") version "<kotest-version>"
}

Add the following dependency to your build:

dependencies {
testImplementation("io.kotest:kotest-framework-engine:<kotest-version>")
}

And then execute the jvmKotest task in gradle, or run tests directly from the IDE.

To use the JUnit Platform plugin, add the following to your build.gradle.kts file:

tasks.withType<Test>().configureEach {
useJUnitPlatform()
}

Add the following dependency to your build:

dependencies {
testImplementation("io.kotest:kotest-runner-junit5:<kotest-version>")
}

And then execute the test task in gradle, or run tests directly from the IDE.

Re-running tests​

By default, Gradle's incremental build will skip running tests if no source code has changed, marking the task as UP-TO-DATE. This can be inconvenient during debugging.

To force your tests to run every time, you can temporarily add the following configuration to your build.gradle.kts file:

tasks.withType<Test>().configureEach {
logger.lifecycle("UP-TO-DATE check for $name is disabled, forcing it to run.")
outputs.upToDateWhen { false }
}

Quick Alternative: For a single re-run without modifying build files, you can use the --rerun flag from the command line:

./gradlew test --rerun