If you’ve used JUnit or another unit testing framework before, some of the ideas might seem familiar. However, don’t worry if you haven’t. Although Spock is built on top of JUnit’s test runner, that’s really just to make the Spock specifications easy to run anywhere JUnit tests can run. The syntax used to express test code in Spock is pretty different.
Spock test classes—known as specifications—are written in Groovy.
Here is a simple Spock specification:
"an integer can be incremented"
This is an extremely straightforward test that just ensures the integer increment operator
0 works as expected.
If you know Java, there are probably some familiar things (the
import statement, class and variable declarations, increment operator, and Boolean expression) and some less familiar things (the
def keyword; weird-looking method names,