BDD Testing with Cucumber
Dev.Talk. Zürich. 19. Sept 2012
Slide 2
Slide 2 text
BDD
Business
• Domain
driven
design
Technology
• Test driven
development
Slide 3
Slide 3 text
Core Principles
1. Enough is enough do as much planning,
analysis, and design as you need, but no
more.
2. Deliver stakeholder value everything
you do should deliver value or increase
your ability to do so.
3. It’s a behavior everyone involved should
have the same way of talking about the
system and what it does.
Slide 4
Slide 4 text
describe the
behavior
of your software
in a very understandable
way
Slide 5
Slide 5 text
1 Describe
Behaviour
2 Write step
definition
3 Run and fail
4 Write code to
make step pass
5 Run and pass
Slide 6
Slide 6 text
Behavior
Feature:
WHO? As a
WHAT? I want
WHY? so that
Scenario:
Given
[And]
When
Then
[And]
Slide 7
Slide 7 text
Step definition
• Regex based
• Reusable
• Cucumber gives you copy & paste code
Slide 8
Slide 8 text
Human Language support
# language: de
Funktionalität: Addition
Um dumme Fehler zu vermeiden
möchte ich als Matheidiot
die Summe zweier Zahlen gesagt bekommen
Szenariogrundriss: Zwei Zahlen hinzufügen
Angenommen ich habe in den Taschenrechner eingegeben
Und ich habe in den Taschenrechner eingegeben
Wenn ich drücke
Dann sollte das Ergebniss auf dem Bildschirm sein
Beispiele:
| Eingabe_1 | Eingabe_2 | Knopf | Ausgabe |
| 20 | 30 | add | 50 |
| 2 | 5 | add | 7 |
| 0 | 40 | add | 40 |
Slide 9
Slide 9 text
What about Java, .net, …?
Java: Cucumber-Jvm
• Pure Java
• Supports: Java, JavaScript, JRuby, Scala,
Python, Groovy, Ioke
.NET: IronRuby
• Cucumber Wrapper for IronRuby
Slide 10
Slide 10 text
Testing possibilities…
• Selenium browser testing
• Webrat acceptance testing
• Interface testing (example mozo poc)
• Many many more – just take a look at the
cucumber tutorials
Slide 11
Slide 11 text
More Information
https://github.com/cucumber/cucumber/wiki
http://behaviour-driven.org/