bdd

27
For more information see www.bbd.co.za and www.drp.co.za Behaviour Driven Development

Upload: robert-maclean

Post on 12-Dec-2014

1.490 views

Category:

Technology


1 download

DESCRIPTION

BDD is an emerging development methodology and this session provides an introduction to it.

TRANSCRIPT

Page 1: BDD

For more information see www.bbd.co.za and www.drp.co.za

Behaviour Driven Development

Page 2: BDD

BDD is a development methodology.BDD is not something new – it is an evolution

Page 3: BDD

No real specNo formal testing

Page 4: BDD

Functional SpecLimited Formal Testing

Page 5: BDD

Functional SpecUnit Tests

Page 6: BDD

“That wasn’t covered by a test”“The code works already, so why write the test”

Page 7: BDD

Functional SpecTDD

Page 8: BDD

Test Driven DevelopmentCode Unit Tests FirstRed – Green – RefactorBetter designs

Page 9: BDD

Testing things that may be changed or irrelevant later

Difficult to understand impactComputer mouse or real mouse?

Page 10: BDD

Functional SpecBDD

Page 11: BDD

Behaviour Driven DevelopmentCoined by Dan North in March 2006

http://blog.dannorth.net/introducing-bdd/

Page 12: BDD

Waterfall, 13%

Iterative, 21%

Agile, 35%

Source: Forrester/Dr. Dobb’s Global Developer Technographics Survey, Q3 2009

Page 13: BDD
Page 14: BDD

Domain Specific Language Gherkin based

Feature Big idea Business case for feature

Scenario testable part of feature Given some input When I am am Then some output

Page 15: BDD

Feature pressing a key, displays the number It is an accepted UI standard to display the numbers on key press so we should do likewise.

Scenario Pressing 1 puts it in the memory buffer Given button input of 1 When I am user Then buffer should contain 1

Scenario Display shows what is in memory buffer Given memory buffer of 1356 When I am a user Then display should show 1356

Page 16: BDD

Feature pressing a key, displays the number It is an accepted UI standard to display the numbers on key press so we should do likewise.

Scenario Pressing 1 puts it in the memory buffer Given button input of 1 And memory buffer is empty When I am user Then buffer should contain 1

Scenario Display shows what is in memory buffer Given memory buffer of 1356 When always Then display should show 1356

Page 17: BDD

Scenario Add a new employee to the system with all values correct should add the employee Given Employee name is Robert MacLean And Employee number is 00001 And Employee Start date is 1 January 2008 And Employee with employee number 00001 is not in data store When I am a user Then the employee is added successfully And verify the employee status is Employed And verify the employee name is Robert MacLean And verify the employee number is 00001 And verify the employee start date is 1 January 2008 and verify the employee end date is empty

Page 18: BDD

From http://www.slideshare.net/giordano/bdd-tdd-and-beyond-the-infinite

Page 19: BDD

Title (one line describing the story) Narrative: As a [role] I want [feature] So that [benefit]

Acceptance Criteria:

Scenarios…

Page 20: BDD

Common language understood by all stakeholdersSets out logically what is needed Familiar to user storiesNot a replacement to functional specs, but an

additionYour thoughts?

Page 21: BDD

Small piece of code to test APIAsserts resultUnit test framework

[TestClass]public class TestAdder{ [TestMethod] public void testSum() { Calc calc = new Calc();   Assert.IsEqual(calc.Add(1, 1), 2); }} 

[TestClass]public class TestAdder{ [TestMethod] public void testSum() { Calc calc = new Calc();   Assert.IsEqual(calc.Add(1, 1), 2); }} 

Page 22: BDD

Small piece of code to action stepAssert resultsUnit test framework

Need specialised frameworkModify the code of an existing framework

Page 23: BDD
Page 24: BDD

Writing specs is hard work Writing stories helped find inconsistencies in specWriting tests was easy for 80% of themDSL was relatively easyStory needed some evolutionCode is really clean

Page 25: BDD

Scenario Add a new employee to the system with all values correct should add the employee

Given Employee name is Robert MacLean And Employee number is 00001 And Start date is 1 January 2008 And Employee with employee number 00001 is not in data storeWhen added by a user Then the employee is added successfully And the employee status is Employeed And verify the employee name is Robert MacLean And verify the employee number is 00001 And the start date is 1 January 2008

Scenario Add a new employee to the system with all values correct should add the employee Given Employee name is Robert MacLean And Employee number is 00001 And Employee Start date is 1 January 2008 And Employee with employee number 00001 I not in data storeWhen I am a userThen the employee is added successfully And verify the employee status is EmployeedAnd verify the employee name is Robert MacLean And verify the employee number is 00001  And verify the employee start date is 1 January 2008 and verify the employee end date is empty

Page 26: BDD

Overall maturity of tools is lowJava, Python & Ruby are strongestC++ &. NET tools exist but immatureUnable to find any VB toolsCommercial tooling & training is very limited

Page 27: BDD