Skip to main content
Version: 6.2 🚧

Setup

The Kotest test framework is supported on all targets, including 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.

[Migrating to Kotest 6]

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.

[Install the IntelliJ Plugin]

Kotest provides an IntelliJ plugin for enhanced UX, including the ability to run individual tests, tool windows to show test layouts, and jump to source.

[Example Project]

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

Kotest on the JVM builds atop of the JUnit Platform project which is widely supported in the JVM ecosystem.

To use the JUnit Platform support, first configure Gradle to use JUnit platform support:

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

Andd then 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.

For enhanced support for jump-to-source and re-running failed tests from the test results tree, add the Kotest Gradle plugin to to your build.

For example:

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

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