qatsi (qatsi) wrote,

Behaviour-Driven Development

Book Review: The Cucumber for Java Book, by Seb Rose, Matt Wynne, and Aslak Hellesøy
I advocated the introduction of the Cucumber testing framework at the place I've just left and saw it adopted with reasonable success. However I do find that there's a limit to being self-taught (especially when you've become the de facto subject matter expert) and I prefer to read up a more official version to find out the bits I've missed and guide towards best practices. This book meets those requirements admirably. I assume it's a derivative of and shares much content with The Cucumber Book, as the first release of the framework was for the Ruby stack. The main difficulty in adopting BDD is philosophical: you can easily find yourself writing an awful lot of code and questioning its value. This was a familiar feeling from my first round of JUnit tests, back in about 2002-3. A further debatable point is how high-level the Gherkin feature descriptions should be: in general the advice is to go for higher level, "stakeholder friendly" feature descriptions, but arguably this gives the developer more discretion in how they are implemented - for example, "the content is not displayed" could mean a 404 web page, or just any old error page. We also had some confusion at work as we'd decided to use Groovy for functional testing because of its rich feature set for working with REST APIs and JSON data structures, although our code was implemented in a Java-esque way; appendices in the book briefly describe the idioms of the Cucumber implementations for Groovy, Scala and Clojure. The book includes descriptions of how to use Cucumber in conjunction with several dependency injection frameworks. Overall the ideal approach would be to build a general purpose library for testing and then to write the Cucumber glue code as a wrapper around it, linking to the Gherkin definitions. The book also contains discussions of Cucumber pain-points and anti-patterns, with useful suggestions on how to avoid or move on from them.
Tags: books, computing
  • Post a new comment


    default userpic

    Your reply will be screened

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.