bdd
DESCRIPTION
BDD is an emerging development methodology and this session provides an introduction to it.TRANSCRIPT
For more information see www.bbd.co.za and www.drp.co.za
Behaviour Driven Development
BDD is a development methodology.BDD is not something new – it is an evolution
No real specNo formal testing
Functional SpecLimited Formal Testing
Functional SpecUnit Tests
“That wasn’t covered by a test”“The code works already, so why write the test”
Functional SpecTDD
Test Driven DevelopmentCode Unit Tests FirstRed – Green – RefactorBetter designs
Testing things that may be changed or irrelevant later
Difficult to understand impactComputer mouse or real mouse?
Functional SpecBDD
Behaviour Driven DevelopmentCoined by Dan North in March 2006
http://blog.dannorth.net/introducing-bdd/
Waterfall, 13%
Iterative, 21%
Agile, 35%
Source: Forrester/Dr. Dobb’s Global Developer Technographics Survey, Q3 2009
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
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
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
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
From http://www.slideshare.net/giordano/bdd-tdd-and-beyond-the-infinite
Title (one line describing the story) Narrative: As a [role] I want [feature] So that [benefit]
Acceptance Criteria:
Scenarios…
Common language understood by all stakeholdersSets out logically what is needed Familiar to user storiesNot a replacement to functional specs, but an
additionYour thoughts?
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); }}
Small piece of code to action stepAssert resultsUnit test framework
Need specialised frameworkModify the code of an existing framework
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
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
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