an introduction to behaviour-driven development · 2020. 6. 18. · example task task: overtime...
TRANSCRIPT
![Page 1: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/1.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se1
Code that matters
An introduction to Behaviour-Driven Development
![Page 2: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/2.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se2
Agenda
• A little bit of background
• The challenge of doing the right thing
• Why TDD alone won't help
• Alternatives
• EasyB
![Page 3: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/3.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se3
Bridging the gap ...
![Page 4: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/4.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se4
![Page 5: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/5.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se5
![Page 6: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/6.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se6
![Page 7: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/7.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se7
![Page 8: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/8.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se8
![Page 9: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/9.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se9
![Page 10: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/10.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se10
![Page 11: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/11.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se11
Card, Conversation, and Confirmation
"... a user story is a reminder tohave a conversation with your customer …"
Scott Ambler, Agile Modeling
![Page 12: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/12.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se12
![Page 13: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/13.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se13
TDD to the rescue?
![Page 14: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/14.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se14
![Page 15: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/15.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se15
"These are not the requirements the
business communicated to us!"
![Page 16: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/16.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se16
TDD can help us build the system right, but it doesn't really help us build the right system.
![Page 17: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/17.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se17
Low level, geeky format
TDD means ...
![Page 18: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/18.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se18
All or nothing, red or green, ...
TDD means ...
![Page 19: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/19.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se19
Working from the inside outstarting with the tiny details,
instead of the big picture
TDD means ...
![Page 20: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/20.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se20
Business people wants to express the required behaviour, not necessarily write tests
![Page 21: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/21.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se21
State required behaviour in a precise enough way, using the
vocabulary of the business
We want to ...
![Page 22: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/22.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se22
State required behaviour using examples
We want to ...
![Page 23: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/23.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se23
Gradually refine and evolve the examples, as the shared
understanding grows
We want to ...
![Page 24: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/24.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se24
Work outside-in, starting with the overall scenarios that gives
business value
We want to ...
![Page 25: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/25.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se25
Same, same, but different
• Close to the original notion of "Customer Tests"
• Known under different names:
– Test-driven Requirements
– Agile Acceptance Tests
– Behaviour Driven Development
![Page 26: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/26.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se26
Lots of available tools and frameworks:
• FitNesse
• Text tool
• RSpec
• Cucumber
• Cuke4Duke
• EasyB
• ...
![Page 27: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/27.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se27
easyb
• A BDD framework forthe Java platform
• Based on Groovy
![Page 28: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/28.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se28
easyb in a nutshell: Story
• Use a natural language, narrative approach
• Describe precise requirements
• Usually made up of a set of scenarios
• Use an easy-to-understand structuregiven ”some context”when ”something happens”then ”something else should happen”
![Page 29: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/29.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se29
Example User Story
White-collar time reporting 5
As a White-collar Employee
I want to record my working time
So that I get correctly calculated salary
![Page 30: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/30.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se30
Example Task
Task: Regular days
Given a white-collar employee
When he arrives at 8:00 and leaves at 17:00
Then his result for that day is 0.
![Page 31: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/31.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se31
Example Task
Task: Flex
Given a white-collar employee with flex
When he arrives at 8:00 and leaves at 18:00
Then his result for that day is +60.
Given a white-collar employee with flex
When he arrives at 8:00 and leaves at 16:00
Then his result for that day is -60.
![Page 32: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/32.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se32
Example Task
Task: Overtime
Given a white-collar employee with flex and overtime
When he arrives at 8:00 and leaves at 19:00
Then his flex result for that day is +120
and his overtime is 0.
Given a white-collar employee with flex and overtime
When he arrives at 8:00 and leaves at 20:10
Then his flex result for that day is +120
and this overtime is +1,5.
![Page 33: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/33.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se33
Demo
![Page 34: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/34.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se35
To summarize:
• TDD can help us build the system right, but that is not enough
• TDR/ATDD/BDD can help us build the right system, by providing a slightly different perspective:
– State required behaviour using examples
– Gradually refine and evolve the examples
– Work from the outside-in
• easyb is a bdd framework for the Java platform, that leverages the power and beauty of Groovy
![Page 35: An introduction to Behaviour-Driven Development · 2020. 6. 18. · Example Task Task: Overtime Given a white-collar employee with flex and overtime When he arrives at 8:00 and leaves](https://reader036.vdocuments.mx/reader036/viewer/2022071018/5fd19954089fed48d97e69a7/html5/thumbnails/35.jpg)
Code that matters © 2011 Callista Enterprise | www.callistaenterprise.se36
Time for Questions!