Earlier this year I was asked to evaluate a book concept about Spock framework. Taking into account that I am a big fan of this library I was extremely happy to see that measures were taken to create a book focused on this particular topic. Hopefully the book will boost even further the popularity of Spock. As always high interest of a product is the best motivation for its authors to continue its development. Few months later, I am given a possibility to read the early edition of this book and as well was asked for a review.
What is Spock?
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?
Groovy is Java
If you are a bit unwilling of learning a new language, imagine you really don’t have to do that! That’s the most amazing thing about Groovy: you can start using it with just some basic experience with Java. How is that possible you ask, the answer is really simple. When you run a Groovy script it will be first compiled to the same JVM bytecode as standard Java classes and then executed by the JVM itself. Hence you can write Groovy scripts in pure Java. What is more, you will be able to use all the libraries written for Java in your scripts (i.e. Spring, Hibernate, Log4j). You have to admit that’s really cool!
Continue reading What is Groovy?