Skip to content

Spock specs, written the way Kotlin wants them.

Spockk is a compiler plugin that brings Spock's expressive given/when/then specification syntax natively into Kotlin: no Groovy, no string DSLs, just real Kotlin code that compiles down to genuine Spock specifications.

WelcomeSpec.kt
kotlin
class WelcomeSpec : Specification() {
  fun `welcome to Spockk`(visitor: Being, greeting: String) {
    given
    val spock = Vulcan("Spock")

    expect
    spock.greet(visitor) == greeting

    where
    visitor         ; greeting
    Vulcan("Sarek") ; "Live long and prosper!"
    Human("Kirk")   ; "Hello!"
  }
}

What is Spockk? ​

Spock is one of the most expressive testing frameworks around, but it's written for Groovy, and speaks with a Groovy accent: dynamic typing, closures-as-blocks, and an AST transform that rewrites your test class before Kotlin ever gets a say.

Spockk adds Kotlin dialect for Spock. It's a Kotlin compiler plugin that recognizes Spock's block-label vocabulary (given, when, then, expect, and, where, cleanup), written as plain, statically-typed Kotlin, and rewrites it at compile time into genuine Spock feature methods. The result runs on Spock's own JUnit Platform engine, right alongside your Groovy specs.

🧬

Native Kotlin syntax

Groovy syntax you are used to as real Kotlin declarations, type-checked by the compiler.

⚙️

Real Spock underneath

Your specs compile down to genuine Spock features, so you keep Spock's runtime behavior.

🧩

Fits your toolchain

Runs on Spock's JUnit Platform engine, so it works with the tools you already use for Kotlin.

Released under the Apache License 2.0.