Skip to main content

An introduction to easyb at Devoxx

Posted by johnsmart on April 21, 2009 at 4:11 PM PDT

Most people would agree that testing your code is a good thing. And there is little
doubt that modern Test-Driven development practices, when applied well, can produce
high quality software that is reliable, flexible and easy to maintain.
However, one of the big problems that often
happens when developers adopt Test-Driven Development is that they concentrate so much on the
tests that they lose focus on what they are actually meant to be testing. This results
in writing large numbers of superficial and inefficient tests, without testing the
underlying user requirements in any real depth.

Behaviour-Driven development is one way to counter this. In Behaviour-Driven development,
you no longer focus on writing tests. Instead,
you concentrate on describing what it is you want your class to do before you start writing
tests. In other words, you describe the behaviour of your class. This is very much in the original
spirit of test-driven development, where the real aim is to design good software - writing tests is very
much a means, not an objective in itself.

Easyb is a fairly new BDD framework based on Groovy. It makes it
very easy to write your tests using a clear, structured and easy-to-understand BDD-style approach.
These test scripts become a very clear way of describing your business requirements, in a way that the end-user can actually understand.
In addition, using Groovy to write your unit tests has many benefits.
In Groovy, you get all the advantages of a scripting language while still being able to access all your Java
classes. But possibly most importantly of all, the highly expressive Groovy language features such as list manipulation
and closures make it a real pleasure to write thorough and comprehensive business-level tests.

In November, I gave a talk on Easyb at the Devoxx conference in Belgium. This is now available online - enjoy!

"Best development course I have been on in a very long time...Greatly enjoyed the course...A 'must' course for serious Java developers..." - Read what people are saying about the Java Power Tools Bootcamps.