KotlinTest 2.0 released


KotlinTest 2.0 was released! It brings new features and polishing.

Syntax can be even more conscise with a lambda passed to the Spec constructor:

class StringSpecExample : StringSpec({

    "strings.size should return size of string" {
        "hello" should haveLength(5)


The new interceptors allow to execute code before and after a test, a class or all classes.

override fun interceptTestCase(context: TestCaseContext, test: () -> Unit) {
    // before
    val started = System.currentTimeMillis()

    test() // don't forget to call test()!

    // after
    val time = System.currentTimeMillis() - started
    println("time [ms]: $time")
  • Simplified ability to add custom matchers. Simple implement Matcher interface.
  • Some new matchers like between(2, 5)
  • Typed tags that can be included or excluded from the tests to be executed.
  • Improved documentation.