Groovier BDD with Spock

Do you create your automated tests in JBehave or Cucumber, but hate it? Have you ever scared a business person by showing them a piece of JUnit test? There is no better, more meaningful and accurate way to communicate about the software we’re developing than tests, so we shouldn’t resign from telling the story about our product just because of crappy BDD tools.

Groovy and Spock are nice alternative to bake BDD specifications directly into the code. By creating domain-specific language it’s possible to create specification understandable both for both business and developers, with IDE support, refactoring and static analysis.

  • Tests are finally not divided into two separate files
  • It is real pleasure to create readable specification: developers can use all the goodness and syntactic sugar that comes with Groovy
  • No need to parse any values from strings into numbers/enums/custom formats — they already are Groovy objects with powerful syntax
  • Fancy automatic formatting with colours is done by IDE itself for free — tests are normal Groovy code
  • IDE navigation to underlying layers of test by CTRL+click
  • No need to do any regexp matching, use clumsy annotations and aliases
Michal Kordas, Luxoft Poland

Michal Kordas, Luxoft Poland

I’m a quality maniac with passion about Java, Groovy, JVM and fancy tools that help to test code in smart, fluent and expressive way. I love bringing feedback loops to the micro-level. my main area of interest is Agile Testing.