So What Do Cucumbers Have To Do With Testing
-
Upload
sjmarsh -
Category
Technology
-
view
5.743 -
download
1
description
Transcript of So What Do Cucumbers Have To Do With Testing
![Page 1: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/1.jpg)
CoastNerds June 2011
So What Do Cucumbers Have To Do With Testing?
Presented By Robert Dyball & Shannon Marsh
![Page 2: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/2.jpg)
Behaviour Driven Development (BDD) BDD Tools StoryQ Demonstration How we use BDD & StoryQ in our Process
CoastNerds Retrospective
What are we going to talk
about?
![Page 3: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/3.jpg)
![Page 4: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/4.jpg)
Behaviour Driven Development
![Page 5: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/5.jpg)
BDD = Behaviour Driven Development BDD
![Page 6: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/6.jpg)
so a test case that looks like this:
public class CustomerLookupTest extends TestCase{
testFindsCustomerById(){
...}
testFailsForDuplicateCustomers(){
...}...
}
rendered to something like this:
CustomerLookup- finds customer by id- fails for duplicate customers- ...
![Page 7: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/7.jpg)
Eric Evans: DDD – Domain Driven Design.
![Page 8: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/8.jpg)
A User Story says:
As a [X] I want [Y] so that [Z]
![Page 9: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/9.jpg)
A User Story says:
As a [X] I want [Y] so that [Z]
BDD says:
Given some initial context (the givens), When an event occurs, then ensure some outcomes.
![Page 10: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/10.jpg)
Given, When, Then
Ubiquitous Language:
![Page 11: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/11.jpg)
TDD versus BDD
So what do you do with TDD
now?
![Page 12: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/12.jpg)
BDD Tools
![Page 13: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/13.jpg)
Cucumber is Aslak Hellesøy’s rewrite of RSpec’s “Story runner”, which was originally written by Dan North.
Is a Ruby tool but can be used with Java, .Net, Flex (Adobe) or web based applications in written in any language.
Tests are written in plain text using the Gherkin syntax.
Cucumber only requires minimal use of Ruby programming.
Cucumber
Ref: http://cukes.info/
Ref: https://github.com/cucumber/cucumber/wiki/
![Page 14: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/14.jpg)
Gherkin Syntax
Ref: https://github.com/cucumber/cucumber/wiki/Gherkin
![Page 15: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/15.jpg)
Cucumber Example
More Examples:http://blog.adyax.com/2009/03/ruby-cucumber/http://blog.spritecloud.com/2010/03/web-testing-with-cucumber/https://github.com/cucumber/cucumber/tree/master/examples/i18n
![Page 16: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/16.jpg)
Java based tool for BDD created by Dan North, et al.
Uses plain text “Gherkin” syntax
Java programming required
Maps to Java based test using annotations
Can integrate into a number of Java testing frameworks including JUnit.
JBehave
Ref: http://jbehave.org/reference/stable/index.html
![Page 17: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/17.jpg)
JBehave Example
![Page 18: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/18.jpg)
JBehave Example
![Page 19: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/19.jpg)
JBehave Example
Ref: http://jbehave.org/reference/stable/index.html
![Page 20: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/20.jpg)
BDD testing framework for .Net
Configurable to work with NUnit, MSTest, XUnit.
Scenarios (specs) are defined in Gherkin syntax in a separate file.
SpecFlow takes the scenarios and turns them into code stubs for tests to be created. (via command line utility)
Scenarios can be data driven using a <placeholder> syntax.
Provides HTML report with summary of all tests as well as details of each scenario.
SpecFlow
Ref: http://www.specflow.org/home.aspx
![Page 21: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/21.jpg)
SpecFlow Example
Ref: http://www.codeproject.com/KB/architecture/BddWithSpecFlow.aspx
![Page 23: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/23.jpg)
BDD for JavaScript
“JSpec is a extremely small, yet very powerful testing framework”
Uses its own custom grammar and pre-processor (ie. Not Gherkin).
Eg. Before_each, describe, it, should_have, end.
Check-out the screen cast for a great demo of how it works and how to setup your tests http://content.screencast.com/users/tjholowaychuk/folders/Jing/media/816a8baa-0175-491a-a138-c889fff99f2d/00000077.swf
JSpec
Ref: http://visionmedia.github.com/jspec/
![Page 26: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/26.jpg)
Puppet is an enterprise system management platform.
Allows you automate system management activities through code.
Cucumber-Puppet has been developed to enable BDD for Puppet.
Similarly Chef is an open-source system integration framework for automating the cloud.
Cucumber-Puppet is a library of tools to enable TDD with Chef and lends it self to BDD.
BDD for System Administrators
Ref:
http://www.cucumber-chef.org/
http://blog.nistu.de/cucumber_puppet_0_0_3_released.html
https://github.com/jtimberman/chef-bdd
http://projects.puppetlabs.com/projects/cucumber-puppet
![Page 27: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/27.jpg)
“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….”
Ref: http://www.cucumber-chef.org/
Why use BDD for System
Administration?
![Page 28: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/28.jpg)
Cucumber-Puppet Example
Setup the fact/s
Create the Test
![Page 29: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/29.jpg)
StoryQ is a portable (single dll), embedded BDD framework for .NET 3.5
It runs within your existing test runner and helps produce human-friendly test output (html or text).
StoryQ's fluent interface adds strong typing, intellisense and documentation to your BDD grammar.
Report in plain text, test results or formated XML
C# coding required.
Featured in tonight’s Demo
StoryQ
Ref: http://storyq.codeplex.com/
http://storyq.codeplex.com/wikipage?title=write%20your%20first%20StoryQ%20testhttp://www.codeproject.com/KB/testing/bddintro.aspx
![Page 30: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/30.jpg)
StoryQ Example
![Page 31: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/31.jpg)
StoryQ Example
![Page 32: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/32.jpg)
RSpec – Ruby - http://rspec.info/
CSpec – C - https://github.com/arnaudbrejeon/cspec/wiki
easyb – Java - http://easyb.org/
storEvil – C# - https://github.com/davidmfoley/storevil/wiki/Why-StorEvil
behat – PHP - http://behat.org/
Kiwi – Apple Objective C - http://www.kiwi-lib.info/
Lettuce – Python - http://packages.python.org/lettuce/tutorial/simple.html
Others…
Ref:
![Page 33: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/33.jpg)
DemonstrationBDD using StoryQ
![Page 34: So What Do Cucumbers Have To Do With Testing](https://reader036.fdocuments.us/reader036/viewer/2022062405/555126e6b4c905325d8b4669/html5/thumbnails/34.jpg)
Discussion: how we use BDD and StoryQ in our process BDD in use