This GIT repository contains all source code for the book Java Testing With Spock published by Manning. Each chapter is offered as an independent Maven project.
You can get an overview of Spock and read a brief discussion on its features in the first chapter of the book. This chapter is freely available in PDF format.
The book contains a comparison of JUnit and Spock using semi-real world code examples. If you are a die-hard JUnit believer, you will find this part of the book very interesting. This chapter is also freely available in PDF format.
To use the code samples you need the following:
You can checkout/run any chapter on its own. You can either work directly on Github or download the code as a ZIP file For each chapter entering the command mvn test will compile and run all JUnit/Spock tests.
Each chapter is self-contained. There is no super POM file. This repository is NOT a multimodule project. If you use Eclipse just import any chapter as a Maven project. If you use IntelliJ make sure that you import each chapter on its own project (and not as modules in a single project). To gain syntax highlighting you also need to install Groovy support in your IDE. This is optional because the build is fully automated via Maven.
There are also build.gradle files along side each maven pom.xml file in each chapter if you would like to see what an analogous gradle build file looks like. You also do not have to download and install Gradle either as the gradle wrapper files are also included in this repository. Simply type ./gradlew clean test at the project root and Gradle will build the project and run the tests.
You can also import the build.gradle files into Eclipse if you have the Gradle Buildship plugin installed. If you are using Intellij IDEA, you can also import each chapter on its own similar to how Maven projects are imported. The idea and eclipse plugins are also configured in each build.gradle file if you want to generate the metadata files for Eclipse and IDEA projects.
Note that Gradle support was contributed by [Mike Smithson] (https://github.com/mikesmithson) and is considered a bonus feature. I will provide no support for Gradle and any related issues, i.e., you are on your own.
If you find a problem with the code feel free to open an issue. If you feel like contributing you can even create a pull request!
If you have comments and suggestions for the book please use the Manning forum. I monitor it regularly and it is helpful if other readers can see and respond to your comments.