First steps with... Cucumber JVM

Cucumber is a tool used to support behaviour driven development. Originally written in Ruby there is now a JVM version, called, quite logically, Cucumber-JVM

The basic idea (very summarized...) is to write acceptance tests for a new feature, together with the product owner, before the code is written. Then run the tests, see the tests fail, implement the missing behaviour, re-run the tests etc.. until the tests pass. 

The key objective here is to involve the product owners as much as possible in writing the tests, which from experience can be tricky as they do not generally have a technical background. So it's important for an acceptance tests framework to generate tests with a syntax which is a close as possible to a natural language. 

Cucumber achieves this quite well, see below for an example Cucumber script (click to zoom in)


The right panel defines the tests scripts to execute, easily understandable by non-technical people. No messing around with HTML either, a big win compared with alternative frameworks such as Fitnesse or Concordion.

The left panel maps the tests scripts to their associated junit tests. Full code source for this example is at: https://github.com/eleco/bdd


Cucumber outputs the tests results in a nicely-formatted page like so.





No comments:

Post a Comment