230 likes | 320 Views
Code Camp NZ 2011. # CCNZ. www.mscommunities.co.nz. About. Agile Coach Manager Methods & Practices Aucklan d DNUG @ Scrumdod Scrumdod.blogspot.com http://www.scrum.org. BDD Overview. What is Behaviour Driven Development? Where did it come from? How did it evolve?
E N D
Code Camp NZ 2011 #CCNZ www.mscommunities.co.nz
About • Agile Coach • Manager Methods & Practices • Auckland DNUG • @Scrumdod • Scrumdod.blogspot.com • http://www.scrum.org
BDD Overview • What is Behaviour Driven Development? • Where did it come from? • How did it evolve? • What tools / frameworks are available? • How do we integrate BDD into our ALM environment?
Founder – Dan North • 2006 ish • http://DanNorth.net • http://dannorth.net/introducing-bdd BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters. – Dan North 2009
Why? • Communication • Outside In – outputs are the only value • TDD Problems
BDD – In the beginning • Tests should output sentences CustomerLookup - finds customer by id - fails for duplicate customers • ... • Output made sense to more than just developers
BDD • Test Methods start with “Should” • This class should do something • Can only define a test for the current class
BDD • An expressive test name is helpful when a test fails • Who has seen this? TestEngineModelFactoryShouldReturn_ZeroValueForIncorrectChecksum
BDD • “Behaviour” is a more useful word than “test”
BDD • Determine the next most important behaviour
BDD • Requirements are behaviour, too • DDD – ubiquitous language
BDD • BDD provides a “ubiquitous language” for analysis • Given When Then, works at many levels As a customer,I want to withdraw cash from an ATM,so that I don’t have to wait in line at the bank. Scenario 1: Account is in creditGiven the Account is in creditAnd the Card is validAnd the Dispenser contains CashWhen the Customer requests CashThen ensure the Account is debitedAnd ensure Cash is dispensedAnd ensure the Card is returned
BDD • Acceptance criteria should be executable public class AccountIsInCredit :Given { public void setup(World world) { ... } } public class CardIsValid :Given { public void setup(World world) {...} } and one for the event: public class CustomerRequestsCash :Event { public void occurIn(World world) { ... } }
BDD • Context Specification / Alternative to GWT As a customer,I want to withdraw cash from an ATM,so that I don’t have to wait in line at the bank. Scenario 1: Account is in creditWhenthe customer requests cash from an account that is in creditIt Should ensure the account is debited
Tools • JBehave -> RBehave -> RSpec -> Cucumber • MSpec • StoryQ • SpecFlow • …
MSpec • Uses Context Specification • Lambdas (love or hate) - = () => • Can output a html report • Cannot use MSTest • Inheritance
StoryQ • Uses Given When Then • Very strict format required • Html output format • One way requirement translation • Parser not runner
SpecFlow • VS Add in • Feature files • Regex • Parser
What about TDD? • Does this replace TDD?
Summary • BDD is about conversations not tools • Can be integrated with ALM process • Works at many levels • Call to action
Thanks to our sponsorsand partners! Sponsor Premier Partners Associated Partners Supporting Partners