Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

So What Do Cucumbers Have To Do With Testing


Published on

All about Behaviour Driven Development (BDD) and some oddly named tools you can use to make it work.

Presented by Robert Dyball and Shannon Marsh

Published in: Technology
  • Be the first to comment

So What Do Cucumbers Have To Do With Testing

  1. 1. CoastNerds June 2011<br />So What Do Cucumbers Have To Do With Testing?<br />Presented By Robert Dyball & Shannon Marsh<br />
  2. 2. Behaviour Driven Development (BDD)<br />BDD Tools<br />StoryQ Demonstration<br />How we use BDD & StoryQ in our Process<br />CoastNerds Retrospective<br />What are we going to talk about?<br />
  3. 3.
  4. 4. Behaviour Driven Development<br />
  5. 5. BDD = Behaviour Driven Development<br />BDD<br />
  6. 6. so a test case that looks like this:public class CustomerLookupTest extends TestCase{<br />testFindsCustomerById() {<br /> ... }<br />testFailsForDuplicateCustomers() {<br /> ...<br /> }<br /> ...<br />}<br />rendered to something like this:<br />CustomerLookup<br />- finds customer by id<br />- fails for duplicate customers<br />- ...<br />
  7. 7. Eric Evans: DDD – Domain Driven Design.<br />
  8. 8. A User Story says:<br />As a [X]<br />I want [Y]<br />so that [Z]<br />
  9. 9. A User Story says:<br />As a [X]<br />I want [Y]<br />so that [Z]<br />BDD says:<br />Given some initial context (the givens),<br />Whenan event occurs,<br />thenensure some outcomes.<br />
  10. 10. Given, When, Then<br />Ubiquitous Language:<br />
  11. 11. TDD versus BDD<br />So what do you do with TDD now?<br />
  12. 12. BDD Tools<br />
  13. 13. Cucumber is AslakHellesøy’s rewrite of RSpec’s “Story runner”, which was originally written by Dan North.<br />Is a Ruby tool but can be used with Java, .Net, Flex (Adobe) or web based applications in written in any language.<br />Tests are written in plain text using the Gherkin syntax.<br />Cucumber only requires minimal use of Ruby programming. <br />Cucumber<br />Ref:<br />Ref:<br />
  14. 14. Gherkin Syntax<br />Ref:<br />
  15. 15. Cucumber Example<br />More Examples:<br /><br /><br /><br />
  16. 16. Java based tool for BDD created by Dan North, et al.<br />Uses plain text “Gherkin” syntax<br />Java programming required<br />Maps to Java based test using annotations<br />Can integrate into a number of Java testing frameworks including JUnit.<br />JBehave<br />Ref:<br />
  17. 17. JBehave Example<br />
  18. 18. JBehave Example<br />
  19. 19. JBehave Example<br />Ref:<br />
  20. 20. BDD testing framework for .Net<br />Configurable to work with NUnit, MSTest, XUnit.<br />Scenarios (specs) are defined in Gherkin syntax in a separate file.<br />SpecFlow takes the scenarios and turns them into code stubs for tests to be created. (via command line utility)<br />Scenarios can be data driven using a <placeholder> syntax.<br />Provides HTML report with summary of all tests as well as details of each scenario.<br />SpecFlow<br />Ref:<br />
  21. 21. SpecFlow Example<br />Ref:<br />
  22. 22. SpecFlow Example<br />Ref:<br />
  23. 23. BDD for JavaScript<br />“JSpecis a extremely small, yet very powerful testing framework”<br />Uses its own custom grammar and pre-processor (ie. Not Gherkin).<br />Eg. Before_each, describe, it, should_have, end.<br />Check-out the screen cast for a great demo of how it works and how to setup your tests<br />JSpec<br />Ref:<br />
  24. 24. JSpec Example<br />Ref:<br />
  25. 25. JSpec Example<br />Ref:<br />
  26. 26. BDD for System Administrators<br />Puppet is an enterprise system management platform.<br />Allows you automate system management activities through code.<br />Cucumber-Puppet has been developed to enable BDD for Puppet.<br />Similarly Chef is an open-source system integration framework for automating the cloud.<br />Cucumber-Puppet is a library of tools to enable TDD with Chef and lends it self to BDD.<br /><br />Ref: <br /><br /><br /><br />
  27. 27. “Cucumber-chef begins with a very simple premise. If we are framing our infrastructure as code - if we’re writing cookbooks, recipes and other pieces of automation in a high level programming language, such as Ruby, then it makes sense to follow the current wisdom across the software development world to maximise the quality, maintainability and reusability of our code, providing maximum chance that we’ll deliver value with it….”<br />Why use BDD for System Administration?<br /><br />Ref: <br />
  28. 28. Cucumber-Puppet Example<br />Setup the fact/s<br />Create the Test<br />
  29. 29. StoryQ is a portable (single dll), embedded BDD framework for .NET 3.5 <br />It runs within your existing test runner and helps produce human-friendly test output (html or text).<br />StoryQ's fluent interface adds strong typing, intellisense and documentation to your BDD grammar.<br />Report in plain text, test results or formated XML<br />C# coding required. <br />Featured in tonight’s Demo<br />StoryQ<br />Ref:<br /><br /><br /><br />
  30. 30. StoryQ Example<br />
  31. 31. StoryQ Example<br />
  32. 32. RSpec – Ruby -<br />CSpec – C -<br />easyb – Java -<br />storEvil – C# -<br />behat – PHP -<br />Kiwi – Apple Objective C -<br />Lettuce – Python -<br />Others…<br />Ref:<br />
  33. 33. Demonstration<br />BDD using StoryQ<br />
  34. 34. Discussion: how we use BDD and StoryQ in our process<br />BDD in use<br />