…
README
Raw ↗[.float-group]
--
image::https://img.shields.io/badge/License-Apache%202.0-blue.svg[link=https://github.com/spockframework/spock/blob/master/LICENSE,float=left]
image::https://github.com/spockframework/spock-example/actions/workflows/main.yml/badge.svg[link=https://github.com/spockframework/spock-example/actions/workflows/main.yml,float=left]
image::https://badges.gitter.im/spockframework/spock.svg[link=https://gitter.im/spockframework/spock?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge,float=left]
--
== Spock Framework Example Project
The purpose of this project is to help you get started with Spock.
The project includes several example specifications and build scripts for Gradle, Maven, and Ant.
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 / Maven / Ant) will automatically download all required dependencies, compile the project, and finally run the example specs.
The Gradle and Maven builds go one step further by bootstrapping themselves, alleviating the need to have a build tool preinstalled.
NOTE: This example shows the usage of Spock 2+, which uses the JUnit Platform.
If you want to see how to get Spock 1.x with JUnit 4 up and running see the https://github.com/spockframework/spock-example/tree/spock-1.x[Spock-1.x] branch.
NOTE: Spock supports Java 8+, but some other parts (newer Groovy version, newer Gradle versions) require newer Java versions.
So for simplicity’s sake the example uses Java 17.
Check the https://github.com/spockframework/spock-example/tree/java-8[Java-8] Branch for the last state of the example with Java 8.
=== Building with Gradle
==== Prerequisites
Any Java version compatible with the Gradle wrapper of the currently used Gradle version installed.
Check `gradle/wrapper/gradle-wrapper.properties` which Gradle version is used, and https://docs.gradle.org/current/userguide/compatibility.html for that version which Java is needed for running the Gradle wrapper.
==== Usage
Type:
[source,bash]
----
./gradlew test --rerun
----
Downloaded files (including the Gradle distribution itself) will be stored in the Gradle user home directory (typically *user_home*`/.gradle`).
=== Building with Maven
==== Prerequisites
JDK 17 or higher installed
==== Usage
Type:
[source,bash]
----
./mvnw clean test
----
Downloaded files will be stored in the local Maven repository (typically *user_home*`/.m2/repository`).
=== Building with Ant
==== Prerequisites
- JDK 17 or higher installed
- Ant 1.10.6
- The `ant-optional` package if it is not already included like in some Linux packages
==== Usage
Type:
[source,bash]
----
ant test
----
Downloaded files will be stored in `ant/lib`.
=== Creating an Eclipse project
Install the https://projects.eclipse.org/projects/tools.buildship[Buildship plugin] if you want to use gradle as build tool.
=== Creating an IDEA project
Just open the project directory with Intelli IDEA and it should auto-detect the project settings.
=== Further Resources
* https://spockframework.org[Spock homepage]
* https://groovyconsole.dev[Spock in the Groovy web console]
* https://docs.spockframework.org[Main documentation]
* https://stackoverflow.com/questions/tagged/spock[Spock on Stackoverflow]
* https://gitter.im/spockframework/spock[Spock Chat]
* https://github.com/spockframework/spock/discussions[Discussion group]
* https://issues.spockframework.org[Issue tracker]
* https://fosstodon.org/@spockframework[Spock on Mastodon]
* https://bsky.app/profile/spockframework.org[Spock on Bluesky]
* https://x.com/SpockFramework[Spock on Twitter]
* https://gradle.org[Gradle homepage]
* https://groovy-lang.org[Groovy homepage]
* https://maven.apache.org[Maven homepage]
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