Skip to main content

Introduction

intro_gif

version badge version badge

Test with Style

Write simple and beautiful tests using one of the available styles:

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

Kotest allows tests to be created in several styles, so you can choose the style that suits you best.

Check all the Tricky Cases With Data Driven Testing

Handle even an enormous amount of input parameter combinations easily with data driven tests:

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

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:

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