Skip to main content
Version: 6.0

Introduction

intro_gif

version badge

Test with Style​

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

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

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 DataTestExample : FreeSpec({
"maximum of two numbers" {
withData(
Triple(1, 5, 5),
Triple(1, 0, 1),
Triple(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 : DescribeSpec({
describe("should use config").config(timeout = 2.seconds, invocations = 10, tags = setOf(Database, Linux)) {
// test here
}
})