Fastest way in
Clone the Spockk Example Project: it's a fully configured Gradle project with a working spec, ready to run.
Prerequisites: JDK 21+ and Kotlin 2.0.0+.
Setting up an existing project takes three small steps.
The Spockk Core module defines the specification syntax for Kotlin and bundles Spock itself, so you don't need to declare it as a separate dependency.
dependencies {
testImplementation("io.github.pshevche.spockk:spockk-core:0.6.0")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:6.1.3")
}
tasks.named<Test>("test") {
useJUnitPlatform()
}The Spockk Gradle plugin wires up the Kotlin compiler plugin that transforms Spockk's expressive syntax into runnable Spock feature methods during compilation. Without it, given/when/then and other constructs are just regular function calls.
plugins {
id("io.github.pshevche.spockk") version "0.6.0"
}Install the Spockk plugin from the JetBrains Marketplace. It teaches IntelliJ to recognize Spockk syntax: correct highlighting for block labels, formatting-aware data tables, and gutter icons to run individual specs or features straight from the editor via Gradle.
That's it: no separate spec runner, no extra configuration. Standard Gradle test tasks pick up Spockk specs automatically.
$ ./gradlew test
> Task :test
BridgeOperationsSpec > raising shields under attack PASSED
BUILD SUCCESSFUL in 2s