The purpose of this project is to help you get started with Spock. The project includes several example specifications and build scripts for Gradle and Maven. It also makes it easy to create an Eclipse or IDEA project, allowing you to run the example specs from within your IDE.
All builds (Gradle and Maven) will automatically download all required dependencies, compile the project, and finally run the example specs. The Gradle build goes one step further by bootstrapping itself, alleviating the need to have a build tool preinstalled.
-
JDK 17 or higher
-
Maven use
mvnwwrapper -
Gradle use
gradlewwrapper
|
Note
|
This example shows the usage of Spock 2.0, which uses the JUnit Platform. If you want to see how to get Spock 1.x with JUnit 4 up and running see the Spock-1.x Branch. |
|
Note
|
Spock supports Java 8, but Groovy 5.0 requires Java 11+ and Gradle 9+ requires Java 17+. So for simplicity’s sake the example uses Java 17. If you want to use an older Java version, please use an older Gradle version (e.g. Gradle 8.x for Java 8+). Check the Java-8 Branch for the last state of the example with Java 8. |
Type:
./gradlew clean testDownloaded files (including the Gradle distribution itself) will be stored in the Gradle user home directory (typically user_home/.gradle).
Type:
./mvnw clean testDownloaded files will be stored in the local Maven repository (typically user_home/.m2/repository).
Install the Buildship plugin if you want to use gradle as build tool.
Just open the project directory with Intelli IDEA and it should auto-detect the project settings.
If you have any comments or questions, please direct them to the Spock discussion group. We appreciate all feedback!
Happy spec’ing!
The Spock Framework Team