Programming language: Kotlin
Tags: Tests    
Latest version: v4.0.0

kotlintest alternatives and similar libraries

Based on the "Tests" category

Do you think we are missing an alternative of kotlintest or a related project?

Add another 'Tests' Library



Build Status GitHub

Kotest is a flexible and comprehensive testing tool for Kotlin with multiplatform support. [Full documentation](doc/reference.md)

Previously known as Kotlintest - From release 4.0 this project is now known as Kotest

For latest updates see [Changelog](CHANGELOG.md)


Test with Style

Write simple and beautiful tests with the StringSpec style:

class MyTests : StringSpec({
  "length should return size of string" {
    "hello".length shouldBe 5
  "startsWith should test for a prefix" {
    "world" should startWith("wor")

Kotest comes with several [testing styles](doc/reference.md#testing-styles) so you can choose one that fits your needs.

Multitude of Matchers

Use over 120 provided matchers to test assertions on many different types:





The withClue and asClue helpers can add extra context to assertions so failures are self explanatory:

withClue("Name should be present") { user.name shouldNotBe null }

data class HttpResponse(val status: Int, body: String)
val response = HttpResponse(200, "the content")
response.asClue {
    it.status shouldBe 200
    it.body shouldBe "the content"

Nesting is allowed in both cases and will show all available clues.

Matchers are extension methods and so your IDE will auto complete. See the [full list of matchers](doc/matchers.md) or write your own.

Let the Computer Generate Your Test Data

Use [property based testing](doc/property_testing.md) to test your code with automatically generated test data:

class PropertyExample: StringSpec({
  "String size" {
    checkAll<String, String> { a, b ->
      (a + b) should haveLength(a.length + b.length)

Check all the Tricky Cases With Data Driven Testing

Handle even an enormous amount of input parameter combinations easily with [data driven tests](doc/data_driven_testing.md):

class StringSpecExample : StringSpec({
  "maximum of two numbers" {
        row(1, 5, 5),
        row(1, 0, 1),
        row(0, 0, 0)
    ) { a, b, max ->
      Math.max(a, b) shouldBe max

Test Exceptions

Testing for [exceptions](doc/reference.md#exceptions) is easy with Kotest:

val exception = shouldThrow<IllegalAccessException> {
  // code in here that you expect to throw an IllegalAccessException
exception.message should startWith("Something went wrong")

Fine Tune Test Execution

You can specify the number of invocations, parallelism, and a timeout for each test or for all tests. And you can group tests by tags or disable them conditionally. All you need is [config](doc/reference.md#config):

class MySpec : StringSpec({
  "should use config".config(timeout = 2.seconds, invocations = 10, threads = 2, tags = setOf(Database, Linux)) {
    // test here

And More ...

This page gives you just a short overview of Kotest. There are many more features:

  • Test whole collections with [Inspectors](doc/reference.md#inspectors).
  • Write elegant conditions with the [matcher DSL](doc/reference.md#matchers-and-assertions): "hello".shouldHaveSubstring("ell").
  • Reuse test logic for setup or tear down, with [Listeners](doc/reference.md#listeners).
  • Test asynchronous code with [whenReady](doc/reference.md#whenReady) and non-deterministic code with [eventually](doc/nondeterministic.md) or [continually](doc/nondeterministic.md)
  • Let Kotest [close resources automatically](doc/reference.md#autoclose): val reader = autoClose(StringReader("xyz"))
  • Handle tricky scenarios such as System Environment with [extensions](doc/extensions.md)
  • Use the [Spring extension](doc/extensions.md#Spring) to automatically inject your spring test classes.
  • Test [Arrow](doc/extensions.md#Arrow) data types with the Arrow extension.
  • Make use of custom plugins for integrations with tools such as [Pitest](doc/plugins.md#Pitest)

See [full documentation](doc/reference.md).


Kotest is split into two main dependencies. Firstly, the framework which provides the ability to layout tests in one of the spec styles and execute them in JUnit or in Mocha. Secondly, the assertion packages. These are provided separately so you can pick and choose which parts you want to use if you don't want to go all in on Kotest.

The following instructions give you the batteries included setup in gradle or maven.


To use in gradle, configure your build to use the JUnit Platform. For Gradle 4.6 and higher this is as simple as adding useJUnitPlatform() inside the tasks with type Test and then adding the Kotest dependency.

Groovy (build.gradle)

test {

dependencies {
  testImplementation 'io.kotest:kotest-runner-junit5-jvm:<version>' // for kotest framework
  testImplementation 'io.kotest:kotest-assertions-core-jvm:<version>' // for kotest core jvm assertions

Android Project (Groovy)

android.testOptions {
    unitTests.all {

dependencies {
    testImplementation 'io.kotest:kotest-runner-junit5:<version>' // for kotest framework
    testImplementation 'io.kotest:kotest-assertions-core-jvm:<version>' // for kotest core jvm assertions

If you are using Gradle+Kotlin, this works for both Android and non-Android projects:

Kotlin (build.gradle.kts)

tasks.withType<Test> {

dependencies {
  testImplementation("io.kotest:kotest-runner-junit5-jvm:<version>") // for kotest framework
  testImplementation("io.kotest:kotest-assertions-core-jvm:<version>") // for kotest core jvm assertions


For maven you must configure the surefire plugin for junit tests.


And then add the Kotest JUnit5 runner to your build.


And for using kotest core jvm assertions add following configurations



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:

repositories {
    maven(url = "https://oss.sonatype.org/content/repositories/snapshots/")

*Note that all licence references and agreements mentioned in the kotlintest README section above are relevant to that project's source code only.