Great projects keep moving forward. JUnit5 is available since September 2017 and Spock 1.2 is already complete. Since Spock is based on JUnit4, I wondered what it would take to use Spock 1.2 together with JUnit5.

As it turns out, it’s quite easy to make that happen. JUnit5 comes with the vintage engine to run JUnit4 based tests. If that is available on the test classpath, your Spock tests run like on JUnit4.

The following example is based on Gradle, and is the minimum to get JUnit5 and Spock working together. It declares the dependencies and instructs Gradle to use the JUnit5 JUnitPlatform to execute the tests.

I have a sample repository that also includes a Maven pom.xml. The repository also includes a JUnit5 test, to prove that a combination of JUnit5 and Spock tests can exist in the same project.

plugins {
  id 'java'
  id 'groovy'

repositories {

sourceCompatibility = 1.8

dependencies {
  testCompile "org.spockframework:spock-core:1.2-groovy-2.5"
  testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.0"
  testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.3.0"

test {

Written with Spock 1.2, JUnit 5.3.0, and Gradle 4.10