Skip to main content
Version: 5.9

Quick Start

Kotest is divided into several, stand alone, subprojects, each of which can be used independently:

You can decide to go all in on Kotest, and use all three together, or you can choose to one or more modules in conjunction with other projects. For example, you could use the assertions library with JUnit, or you could use the test framework with another assertions library like assertj.

This page gives setup instructions for various combinations of projects and targets.

note

Kotest is a multi-platform project. If you are unfamiliar with this, then Kotlin compiles to different targets - JVM, JS, Native, iOS and so on. If you are doing server side or android development then you want the modules that end with JVM, such as kotest-property-jvm.

Test Framework​

The Kotest test framework is supported on JVM, Javascript and Native. To enable Kotest for multiple platforms, combine the steps for the individual platforms as detailed in the following tabs.

Kotest on the JVM uses the JUnit Platform gradle plugin. For Gradle 4.6 and higher this is as simple as adding useJUnitPlatform() inside the tasks with type Test and then adding the Kotest junit5 runner dependency.

If you are using Gradle + Groovy then:

test {
useJUnitPlatform()
}

Or if you are using Gradle + Kotlin then:

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

And then the dependency:

testImplementation 'io.kotest:kotest-runner-junit5:$version'

Assertions Library​

The core assertions library framework is supported on all targets. Submodules are supported on the platforms that applicable. For example, the JDBC matchers only work for JVM since JDBC is a Java library.

Add the following dependency to your build:

testImplementation 'io.kotest:kotest-assertions-core:$version'

Property Testing​

The property test framework is supported on all targets.

Add the following dependency to your build:

testImplementation 'io.kotest:kotest-property:$version'

Snapshots​

Snapshot are automatically published on each commit to master. If you want to test the latest snapshot build, setup the same way described above, change the version to the current snapshot version and add the following repository to your repositories block:

https://oss.sonatype.org/content/repositories/snapshots