Quick Start
Kotest is a flexible and comprehensive testing project for Kotlin with multiplatform support.
For latest updates see Changelog.
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.
Kotest is a multiplatform 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, Android, Javascript and Native. To setup kotest as your testing framework, follow detailed instructions in the framework documentation page.
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.
- JVM/Gradle
- JVM/Maven
- Multiplatform
Add the following dependency to your build:
testImplementation 'io.kotest:kotest-assertions-core:$version'
Add the following dependency to your build.
<dependency>
<groupId>io.kotest</groupId>
<artifactId>kotest-assertions-core-jvm</artifactId>
<version>{version}</version>
<scope>test</scope>
</dependency>
Add the following dependency to your commonTest dependencies block:
implementation 'io.kotest:kotest-assertions-core:$version'
Alternatively, add the dependency to a specific target. For example, we could add to the Javascript target only.
kotlin {
targets {
js {
browser()
nodejs()
}
}
sourceSets {
val jsTest by getting {
dependencies {
implementation("io.kotest:kotest-assertions-core:$version")
}
}
}
}
View the assertions library documentation for more information.
Property Testing​
The property test framework is supported on all targets.
- JVM/Gradle
- JVM/Maven
- Multiplatform
Add the following dependency to your build:
testImplementation 'io.kotest:kotest-property:$version'
Add the following dependency to your build.
<dependency>
<groupId>io.kotest</groupId>
<artifactId>kotest-property-jvm</artifactId>
<version>${version}</version>
<scope>test</scope>
</dependency>
Add the following dependency to your commonTest dependencies block:
implementation 'io.kotest:kotest-property:$version'
Alternatively, add the dependency to a specific target. For example, we could add to the Javascript target only.
kotlin {
targets {
js {
browser()
nodejs()
}
}
sourceSets {
val jsTest by getting {
dependencies {
implementation("io.kotest:kotest-property:$version")
}
}
}
}
View the property testing documentation for more information.
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://s01.oss.sonatype.org/content/repositories/snapshots