Preface
The first time Spock came onto my programming radar (which is always on, looking for interesting news in the Java ecosystem) I have to admit it didn’t get the attention it deserved. I briefly read its web page and originally thought that it was the equivalent of JUnit but for the Groovy programming language instead of Java. Since I mainly write Java code professionally, a Groovy testing framework wasn’t of much interest to me at that time. I moved along to the next news item of my RSS reader. Big mistake!
Groovy was already very high up on my list of “things that I needed to evaluate” and I kept researching it. I was especially interested in how it connects to Java and the ways it augments your existing Java code base. I learned that Groovy code compiles to the same bytecode as Java, that it also runs on the JVM, and that adding Groovy to a Java code base is as simple as adding the Groovy jar in the Java classpath.
Then it dawned on me: if Java and Groovy code are so close together, can I use Spock (which is the Groovy testing tool) to test Java code? And could I use JUnit to test Groovy code? Coming from a programming background with big Java codebases, I was of course very interested in the first question.