Great projects keep moving forward. JUnit5 is available since september 2017 and Spock 1.2 was completed in september 2018. 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 a 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 for getting started in gradle. It declares the dependencies and instructs gradle to use the JUnit5
JUnitPlatform to execute the tests.
I have a sample repository that 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.
Written with Spock 1.2, JUnit 5.3.0, and Gradle 4.10