Introducing bdd elements to unit testing.pptx
-
Upload
anders-hammervold -
Category
Technology
-
view
1.008 -
download
0
description
Transcript of Introducing bdd elements to unit testing.pptx
![Page 1: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/1.jpg)
Experiences introducing BDD and BDD elements
To unit testing and a legacy codebase
XP 2010, June 3rd 2010
![Page 2: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/2.jpg)
Background
A local, familyman, 2 children
Developer, Consultant
BEKK Consulting
10+ years
Seen many types of projects
@ah74
hammervold.com/anders
![Page 3: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/3.jpg)
Background: What I had seen a lot of
POUT
Some testclasses of several k+ lines
Often excellent testcode
Difficult to understand for others
Difficult to come back to after some time away
Focus on test techniques like Mocking
Refactoring later would mean rewriting complex code AND complex tests
in a hurry? remove tests that are red
![Page 4: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/4.jpg)
BDD and ”BDD elements”
BDD
Started seeing BDD inspired syntax and thinking
Ground up
Which effect did this have ?
Did it correspond with the goals of BDD?
What was happening in other projects right now ?
Examples
![Page 5: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/5.jpg)
Example: BDD using Cucumber features
http://www.engineyard.com/blog/2009/cucumber-introduction/
![Page 6: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/6.jpg)
Example: ”BDDTest”
Adapted from and inpired by code and examples from: Torbjørn Marø and Jonas follesø
![Page 7: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/7.jpg)
Example: ”BDDTest” adapted
![Page 9: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/9.jpg)
Experiment: Regions
Experimental,
IDE-specific
![Page 10: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/10.jpg)
Effects: The skeptic
”I know how to write tests”
![Page 11: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/11.jpg)
Effects: The skeptic
”Wow this test became so much simpler!”
”This was almost fun”
![Page 12: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/12.jpg)
How
~20 minute interviews
– Developers
– Testers
– Customers
5 different projects
– May 2010
![Page 13: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/13.jpg)
Objections?
Some arguments used were the same as against TDD
Fear of change
Technical problems, sometimes new technology
Unwillingness to learn something new
Not true BDD, outside in through ui
![Page 14: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/14.jpg)
Developer perspective
Clear sense of purpose
Recipe to follow
Renewed focus on specification
Smaller, simpler tests
Easier to maintain
Most tests now got a similar structure
Greater number of tests but better organised
”I give up, i’ll rather go write some BDD-tests,
maybe that will cheer me up”
![Page 15: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/15.jpg)
Customer perspective
”The bug-rate dropped significantly”
”I could see that they (the developers) had understood what I meant”
”I never understood the code anyway”
– Generally responded well to the syntax
– Customers were generally more agile than developers perhaps expected
– When given a chance
– Clarifying requirements
![Page 16: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/16.jpg)
Success
Many of the results can be attributed to TDD
BDD elements added to and amplified these
Skeptics became ”believers”
The customers showed greater involvement
Testers could write features in the error report
![Page 17: Introducing bdd elements to unit testing.pptx](https://reader033.fdocuments.us/reader033/viewer/2022052622/558cbfeed8b42a76788b45ba/html5/thumbnails/17.jpg)
Some success-criteria
Access to a mentor
Commitment from the team
Willingness to learn
Including the customer