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.
BDD with Cucumber-JVM

Thomas Sundberg

Developer
Stockholm,  Sweden

Think Code AB
thomas@thinkcode. se
@thomassundberg

...
What Why How When
W i i ;   17
A collaboration tool
C
C
4:
WV i H gr
Communication

depends on the audience
imunication

depends on the audience
BDD is business facing

‘     , -

, , ,1
Any reasonable person can read, 
and understand,  an example
Scenario:  Observe a change in our system
Given a precondition
When we use the system
Then should we be able to observe a ...
Scenario:  Addition
Given a running calculator

When I add 17 and 42
Then should the calculator display 59
Scenario:  Add an item in the shopping bag
Given I have selected a red t-shirt
When I add the t-shirt to the shopping bag
...
Use the language of the business, 
a ubiquitous (common) language
and concrete examples

There is nothing so annoying as a...
the language oi the business, 
iquitous (common) language
concrete examples

There is nothing so annoying as a good exampl...
JIICI I'III

/  Headli
Feature:  Subscribe for our e—mail marketing service

In order to be able to receive important mark...
Gherkin

/  Headline
Feature:  Subscribe for our e—mail marketing service

In order to be able to receive important market...
Concrete is hard
Imperative or Declarative?
I II ‘I If I  I’ It I  3

How stuff should be executed

I". 
F    —, ,[ 1;] [if l. F7.‘ lF'! VYI:  / .IF'(,  3‘
—   

What...
VVIICAL VVC C/ |xJCJL

Prepare for changes

They will occur
Imperative

How stuff should be executed

Declarative

What we expect

Prepare for changes
Feature:  Subscribe for our e—mail marketing service Feature:  Subscribe for our e—mail marketing service

In order to be ...
Feature:  Subscribe for our e—mail marketing service

In order to be able to receive important marketing messages
As marke...
Feature:  Subscribe for our e—mail marketing service

In order to be able to receive important marketing messages
As marke...
Feature:  Subscribe for rv‘ “eting service Feature:  Subscribe for our e—mail marketing service

In order to be abl eive i...
BDD can help us build the right thing

Creates confidence that the system behaves
as our customer want it to behave

Creat...
What Why How When
Gather the right persons
I II I‘Isw  III I I 2
.  . ,  ' ’ I  .  . rqij ' T

 -‘-‘ Slxacrecol I. Lr0(4.f~3l-w: ¢14.»/ ~fl

“W;  bio ol. i.SLLi. S.Si...
Discovery Workshop
Example Mapping
( li'_‘_'''': |'' 3/
2%
I Mi use

 

Workshop Example Mapping

Discuss and document the requirements as features

A requir...
as and document the requirements as features

A requirement may consist of many scenarios
How does it work?
Execute .  . Assert
specification ‘ change

I P I LII 1
Execute I .  Observe

SUT ’ ‘ change
- , _-rc, 

I-IVI I ). I I I III III
What Why How When
IflIIniII
Not always
This is not a new silver bullet
;5I. III’I

I

“~‘3“o'II9 Sc.  plrcczrlzercr
Probe .   I C - fie
Sense ’ ' , ' , 

Respond “‘-K

    
 

Emergent

   

(‘I...
Sense
Categorize
Respond

Best Practice
Complex

Probe
Sense
Respond

Emergent
:‘3I‘Io‘I4I”I35‘ ‘ is I‘ Iir: c:'I'eIcC
robe .   I * S A , ‘e
Sense I in,  ,
Respond ‘espaw
Emergent COL —I_n T,  _

SEVIS...
Behaviour Driven Development
is a collaboration tool

 

One single source of truth
Do you want to know more? 

Training? 

Consulting? 

Contact me!
BDD with Cucumber-JVM

Thomas Sundberg

Developer
Stockholm,  Sweden

Think Code AB
thomas@thinkcode. se
@thomassundberg

...
Bdd with Cucumber-jvm. Java Day, Kiev 2015
Bdd with Cucumber-jvm. Java Day, Kiev 2015
Bdd with Cucumber-jvm. Java Day, Kiev 2015
Bdd with Cucumber-jvm. Java Day, Kiev 2015
Upcoming SlideShare
Loading in …5
×

Bdd with Cucumber-jvm. Java Day, Kiev 2015

638 views

Published on

As presented at Java Day Kiev 2015

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Bdd with Cucumber-jvm. Java Day, Kiev 2015

  1. 1. BDD with Cucumber-JVM Thomas Sundberg Developer Stockholm, Sweden Think Code AB thomas@thinkcode. se @thomassundberg http: //thomassundberg. wordpress. com http: //www. thinkcode. se
  2. 2. What Why How When
  3. 3. W i i ; 17
  4. 4. A collaboration tool
  5. 5. C C 4:
  6. 6. WV i H gr
  7. 7. Communication depends on the audience
  8. 8. imunication depends on the audience
  9. 9. BDD is business facing ‘ , - , , ,1
  10. 10. Any reasonable person can read, and understand, an example
  11. 11. Scenario: Observe a change in our system Given a precondition When we use the system Then should we be able to observe a change
  12. 12. Scenario: Addition Given a running calculator When I add 17 and 42 Then should the calculator display 59
  13. 13. Scenario: Add an item in the shopping bag Given I have selected a red t-shirt When I add the t-shirt to the shopping bag Then should the shopping bag contain a red t-shirt I Inn fldr
  14. 14. Use the language of the business, a ubiquitous (common) language and concrete examples There is nothing so annoying as a good example Mark Twain
  15. 15. the language oi the business, iquitous (common) language concrete examples There is nothing so annoying as a good example Mark Twain
  16. 16. JIICI I'III / Headli Feature: Subscribe for our e—mail marketing service In order to be able to receive important marketing messages As marketing message receiver I should be able to register my e—mail address Intro Scenario: Subscribe with a valid e—mail address Given I want to subscribe to receive important market information When I enter a valid address thomas@thinkcode. se & Then should I get a welcome message SCE stric Scenario: Try to subscribe with an invalid e—mail address / Given I want to subscribe to receive important market information When I enter an invalid address thomas. thinkcode. se Then should I get an error message
  17. 17. Gherkin / Headline Feature: Subscribe for our e—mail marketing service In order to be able to receive important marketing messages As marketing message receiver I should be able to register my e—mail address _ Introduction, free text Scenario: Subscribe with a valid e—mail address Given I want to subscribe to receive important market information When I enter a valid address thomas@thinkcode. se K _ Then should I get a welcome message SCenal|0r strict Gherkin syntax Scenario: Try to subscribe with an invalid e—mail address / Given I want to subscribe to receive important market information When I enter an invalid address thomas. thinkcode. se Then should I get an error message
  18. 18. Concrete is hard
  19. 19. Imperative or Declarative?
  20. 20. I II ‘I If I I’ It I 3 How stuff should be executed I". F —, ,[ 1;] [if l. F7.‘ lF'! VYI: / .IF'(, 3‘ — What we expect Prepare for changes They will occur
  21. 21. VVIICAL VVC C/ |xJCJL Prepare for changes They will occur
  22. 22. Imperative How stuff should be executed Declarative What we expect Prepare for changes
  23. 23. Feature: Subscribe for our e—mail marketing service Feature: Subscribe for our e—mail marketing service In order to be able to receive important marketing messages In order to be able to receive important marketing messages As marketing message receiver As marketing message receiver I should be able to register my e—mail address I should be able to register my e—mail address Scenario: Subscribe with a valid e—mail address Scenario: Subscribe with a valid e—mail address Given I open my browser to www. exampIe. com/ subscribe Given I want to subscribe to receive important market information when I type tsu@kth. se in the textarea ep When I enter a valid address tsu@kth. se And press the send—ep button Then should I get awelcome message Then should I be fonrvarded to a page with the title subscription result And see Welcome tsu@kth. se in the div message
  24. 24. Feature: Subscribe for our e—mail marketing service In order to be able to receive important marketing messages As marketing message receiver I should be able to register my e—mail address Scenario: Subscribe with a valid e—mail address Given I open my browser to vwvw. examp| e.com/ subscribe When I type tsu@kth. se in the textarea ep And press the send—ep button Then should I be forwarded to a page with the title subscription result And see Welcome tsu@kth. se in the div message
  25. 25. Feature: Subscribe for our e—mail marketing service In order to be able to receive important marketing messages As marketing message receiver I should be able to register my e—mail address Scenario: Subscribe with a valid e—mail address Given I want to subscribe to receive important market information When I enter a valid address tsu@kth. se Then should I get a welcome message
  26. 26. Feature: Subscribe for rv‘ “eting service Feature: Subscribe for our e—mail marketing service In order to be abl eive importar. keting messages In order to be able to receive important marketing messr As marketing m M eiver As marketing message receiver I should be abl/ ‘ regr. I e—mail addI I should be able to register my e—mail address Scenario: Sub re with a v Inail adI 5 Scenario: Subscribe with a valid addrer Given I open I nrowser to I. amp Jm/ subscribe Given I want to subscribe to I a information when I type ts Ih. se in the 1; ' When I enter a valid address is And press the S. In button Then should I get awelcome mess Then should I be I. ' ’—'-Lu rth the title subscription result And see Welcome tsp, div message
  27. 27. BDD can help us build the right thing Creates confidence that the system behaves as our customer want it to behave Creates confidence that can release
  28. 28. What Why How When
  29. 29. Gather the right persons
  30. 30. I II I‘Isw III I I 2 . . , ' ’ I . . rqij ' T -‘-‘ Slxacrecol I. Lr0(4.f~3l-w: ¢14.»/ ~fl “W; bio ol. i.SLLi. S.Si‘4:3 . £J<a¢a~«I0(ZS I F lExa__, mI0 (LS tt 0 Po 1% i Q“ SE _. _j. ____j_. ... _. _.. "L. _ Discovery Workshop Example Mapping
  31. 31. Discovery Workshop
  32. 32. Example Mapping
  33. 33. ( li'_‘_'''': |'' 3/ 2% I Mi use Workshop Example Mapping Discuss and document the requirements as features A requirement may consist of many scenarios
  34. 34. as and document the requirements as features A requirement may consist of many scenarios
  35. 35. How does it work?
  36. 36. Execute . . Assert specification ‘ change I P I LII 1 Execute I . Observe SUT ’ ‘ change
  37. 37. - , _-rc, I-IVI I ). I I I III III
  38. 38. What Why How When
  39. 39. IflIIniII
  40. 40. Not always
  41. 41. This is not a new silver bullet
  42. 42. ;5I. III’I I “~‘3“o'II9 Sc. plrcczrlzercr Probe . I C - fie Sense ’ ' , ' , Respond “‘-K Emergent (‘Ii f» 1%. ?‘-F , ‘x. .II‘: ‘ In Ia ILEIC ACIZ Sense Seme- Categorize Respond Respond NOV“ Best Practice Dave Snowden
  43. 43. Sense Categorize Respond Best Practice
  44. 44. Complex Probe Sense Respond Emergent
  45. 45. :‘3I‘Io‘I4I”I35‘ ‘ is I‘ Iir: c:'I'eIcC robe . I * S A , ‘e Sense I in, , Respond ‘espaw Emergent COL —I_n T, _ SEVISE se‘"'S_e Categorize Re5p°”d Respond N0‘/9' Best Practice Dave Snowden
  46. 46. Behaviour Driven Development is a collaboration tool One single source of truth
  47. 47. Do you want to know more? Training? Consulting? Contact me!
  48. 48. BDD with Cucumber-JVM Thomas Sundberg Developer Stockholm, Sweden Think Code AB thomas@thinkcode. se @thomassundberg http: //thomassundberg. wordpress. com http: //www. thinkcode. se

×