Skip to content
Powerful, elegant and flexible test framework for Kotlin
Branch: master
Clone or download

Latest commit

Octogonapus Add existInOrder and should(Not)ExistInOrder matchers (#1465)
* #1460: Add existInOrder and should(Not)ExistInOrder matchers.
Latest commit b4c582c May 29, 2020


Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Fix gradle task name in workflow file (#1450) May 22, 2020
buildSrc Updated default property function to throw NoGeneratorFoundException Apr 28, 2020
doc Update May 28, 2020
gradle/wrapper Sanitized some use of mocks #1391 (#1392) Apr 21, 2020
kotest-assertions Add existInOrder and should(Not)ExistInOrder matchers (#1465) May 29, 2020
kotest-core Makes beforeProject and afterProject as suspend function (#1461) May 26, 2020
kotest-examples Support multi line test name in results and focus (#1444) May 18, 2020
kotest-extensions Makes beforeProject and afterProject as suspend function (#1461) May 26, 2020
kotest-fp Fix native publishing. (#1449) May 22, 2020
kotest-mpp Fix native publishing. (#1449) May 22, 2020
kotest-plugins/kotest-plugins-pitest Makes beforeProject and afterProject as suspend function (#1461) May 26, 2020
kotest-property Fixed issues 1435 Add before and after test listeners to property ba… ( May 23, 2020
kotest-runner Makes beforeProject and afterProject as suspend function (#1461) May 26, 2020
kotest-samples Remove invocations from config #1165 Feb 9, 2020
kotest-tests Makes beforeProject and afterProject as suspend function (#1461) May 26, 2020
.editorconfig Added test for first/last cause in eventually Mar 7, 2020
.gitignore Fixed bug with project conf parallelism, after/before methods, and ma… Feb 23, 2020 Update Apr 26, 2020
LICENSE Update LICENSE Mar 22, 2016 Fixed style of badges to match May 11, 2020
build.gradle.kts Removed android plugin Mar 25, 2020 Fix native publishing. (#1449) May 22, 2020
gradlew Bump gradle wrapper version 5.6.2 (#1027) Oct 1, 2019
gradlew.bat Bump gradle wrapper version 5.6.2 (#1027) Oct 1, 2019 Updated docs with kotest details #1209 Feb 16, 2020
nopublish.gradle Trying to not publish test modules Feb 16, 2020
publish-mpp.gradle.kts Feature/discovery (#1271) Mar 9, 2020
settings.gradle.kts Renamed framework tests module Apr 13, 2020


Build Status GitHub

Kotest is a flexible and comprehensive testing tool for Kotlin with multiplatform support.

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

For latest updates see Changelog.
Read full documentation or a quick start guide.


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 so you can choose one that fits your needs.

Multitude of Matchers

Use over 300 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") { 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 or write your own.

Let the Computer Generate Your Test Data

Use property based testing to test your code with automatically generated test data:

class PropertyExample: StringSpec({
  "String size" {
    checkAll<String, String> { a, b ->
      (a + b) shouldHaveLength 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:

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 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:

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:

See our getting started section or full documentation.

Read more about Kotest from third party blogs and articles.

You can’t perform that action at this time.