This is a copy/MD-conversion of the original article by Lukasz Janicki: Spock Testing – Spock tutorial – The Javatar . The webpage is no longer available, but this cheat-sheet is too good to loose! A simpler full demo of a Spock implementation can also be found here.
Spock is a unit testing framework that in great extent utilizes Groovy’s syntax making your tests comprehensible and easy on the eyes. Although it is a Groovy technology you can use it to test your Java classes as well. What is the most important is that Spock makes writing tests fun. And I really mean it.
I have to admit that even knowing all the benefits of TDD and tests over all I considered writing them as little pain in the neck. How has that changed when I started using Spock?
- Creating a test in Spock takes less time than using its sta