The status quo in unit testing
Inertia is the biggest enemy of innovation. People want to work with familiar tools and upgrading to a newer tool is always a big challenge if re-training is required. Even though software development is considered a progressive discipline with a continuous flow of new technologies, there are still some areas when the status quo goes unchallenged.
One such area is the automated testing of Java applications at the code level (also known as unit testing). The undisputed king of unit testing is currently JUnit (http://junit.org) and has been since the beginning of time. JUnit is stable, mature, well known and most importantly a part of the xUnit family of testing frameworks that govern most programming languages.
JUnit is deeply entrenched in the mind of Java developers; some of them even go as far to believe that unit tests and JUnit code are a tautology. JUnit is of course one of the possible ways to perform unit testing, but not the only one. For a brief period in time, TestNG (http://testng.org/) attempted to challenge JUnit out of its throne but without any luck. All innovative features of TestNG were quickly ported to JUnit ending the battle in one swift blow.
Now a new contender has entered the area of testing frameworks: Spock, the groovier testing library (http://docs.spockframework.org)!
Spock: a new unit testing framework
It is based on the Groovy programming language (http://www.groovy-lang.org/) but can equally test Java as well as Groovy code. The big advantage Spock brings to the table is its holistic approach to unit testing:
Spock has entered the arena after studying the main weakness of JUnit. JUnit is simply not enough for today’s enterprise applications. It can only offer basic unit testing abilities. As soon as further testing requirements appear (such as mocking or BDD style specification), JUnit falls flat.
Spock offers instead a comprehensive testing package that covers all the needs of an enterprise application regardless of its size. Unlike JUnit it also comes with an expressive testing language (a testing DSL) that is even understandable by non-technical people. Business analysts will particularly like the Spock testing syntax.
In summary, Spock can function as the main building block in a sound testing process, covering all areas from the basic code testing, up to functional tests and it would be a worthy addition to your toolset, even if you believe that JUnit is the only solution when it comes to unit testing.
Trasys is already using Spock in production and so should you!
Konstantinos Kapelonis – Senior Software Engineer