SlideShare a Scribd company logo
Behaviour Driven Development With NBehave Linking User Stories and Domain Driven Design to Testing David Ross W: www.pebblesteps.com E: willmation@gmail.com
Behavior Driven DevelopmentTools and techniques Talk overview ,[object Object],  Topics  ,[object Object]
Top down and Bottom up Testing
NBehaveUsing library Using the test runner ,[object Object]
Acceptance testing,[object Object]
Behavior Driven Development BDD is not: a testing framework or style of testing a method for writing tests BDD is: A formalised template for User Stories Able to create testable User Stories since they are defined in a formal manner Promotes “security” to a first call citizen in the analysis process
Simple Trading application Excel spreadsheet replacement
Allow Portfolio Manager to decide the percentage split between Cash, Property and Stock within the Portfolio Inform the Trader when the Portfolio needs to be rebalanced (ie split in the pie has changed significantly) Allow Operations to standardise Portfolio names Simple Trading application Requirements
Test First Development Small steps Red - Analysis/Design Hat ,[object Object]
Asking "What I want is...“Green - Creative Hat (Fun part) ,[object Object],Refactor- Engineering ,[object Object],Red Green Refactor
Test First DevelopmentHow easy is it to use TFD for the following Requirement/Story Value = Units * Market Price Increase the performance of the User Security module by automatically caching the user’s manager Id The system must email the Portfolio manager when the Portfolio needs to be rebalanced Build a web site so that customers can see the performance of the portfolio
Test First DevelopmentDo you feel guilty??	 Do you write a Failing unit test before every piece of code? Do you write a line of Unit Test code for EVERY line of production code?
Behavior Driven How do you write a test when you don’t know where you are going?  Maybe we need requirements that are easy to write tests for?
RequirementsWhat are they Describes what a system should do but not how it will be done Contract between the implementation team and the analysis team Audience is typically the stake holders and not the development team
Requirements Precise and clear over verbose We want requirements that    ,[object Object]
Are attainable!!! 
Are traceable into code!!!,[object Object]
BDD User StoriesFormal template for User Stories Story Template As a [User/Role]I want [Behaviour]so that [I receive benefit] Example As a “Operations staff member”I want “To create a Portfolio”so that“So that it can be traded”
BDD User StoriesFormal template for User Stories Scenario Template Given some initial context (the givens),When an event occurs,then ensure some outcomes. Example Given “New portfolio is called Balanced Fund”When “Portfolio already exists”then “Portfolio can no be created”
.NET Library for writing automated BDD style tests Fluent syntax for building up a BDD Style User Stories Test runner that executes the stories and generates a report listing the contents of the stories NBehave What is it?
Creating a BDD Theme Collection of related stories [Theme("Portfolio Maintenance")] public class PortfolioMaintenanceStory { [Story] public void portfolio_create_story () { ... } [Story] public void portfolio_delete_story() { ... } } Reference:NBehave.Narrator.Framework.dll
Creating a Story  Fluent interface to define the story var story = new Story("Create portfolio"); story.AsA(“Operations team member") 	.IWant("To create a new portfolio on behalf of a portfolio manager") 	.SoThat("the portfolio manager can configure the portfolio and the front office can trade");
Creating a Scenario Fluent interface to define the story story.WithScenario("portfolio does not exist") .Given("portfolio name is $name", "Aggressive Fund") .When("portfolio does not exist in the database") .Then("new portfolio should be created"); story.WithScenario("portfolio already exists") 	.Given("portfolio name is $name", "Aggressive Fund") 	.When("portfolio already exists in database") 	.Then("an error should occur");
Executing the test WithNBehave runner or mbUnit Ouch we get an error??? The scenario throws an exception – NBehave isn’t validating any code Use Pending story.WithScenario("portfolio does not exist") 	.Pending("In progress") 	.Given("portfolio name is $name", "Aggressive Fund") 	.When("portfolio does not exist in the database") 	.Then("new portfolio should be created");
Behavior Driven Development Across the Project (Story) Life Cycle Story Pending Scenario Stubbed Behavior Cycle (Red, Green, Refactor) Real Behavior Cycle (Red, Green, Refactor) Acceptance Test
Stubbing out the behavior WithNBehave and Rhino.Mocks Steps to generate an API Go through the User story and find all the domain objects Create a class for each domain object but don’t add state Go through the User story and create a find all the services that are required (Repositories etc) Create an interface for each service but don’t add any methods
Steps to generate the API continued... Slowly implement the story Add domain object properties as required Add methods signatures as required Use Stubs to explore Inputs/Outputsto the methods Stubbing out the behavior WithNBehave and Mocking
Stubbing example Create a new portfolio story stringportfolioName = ""; Portfoliop = null; varportfolioRepository = MockRepository.GenerateStub<IPortfolioRepository>(); varportfolioService = MockRepository.GenerateStub<IPortfolioService>(); s.WithScenario("portfolio already exists") 	.Given("portfolio name is $name", "Aggressive Fund",   n => { portfolioName= n; 		p = new Portfolio { Name = portfolioName }; portfolioRepository. 			Stub(x => x.FindPortfolioByName(portfolioName)).Return(p); portfolioService. 			Stub(X => X.CreatePortfolio(p)).Throw(new ItemExistsException()); 		})
Stubbing example Create a new portfolio story .When("portfolio already exists in database", 	 () => Assert.IsNotNull( portfolioRepository.FindPortfolioByName(portfolioName)) 	) .Then("new portfolio create should fail", 	() => Assert.Throws<ItemExistsException>(() => portfolioService.CreatePortfolio(p)) 	);
TFD/BDD Comparison Behavior Driven ,[object Object]
Design starting with interfaces (using stubs)
Back fill with code later  Output ,[object Object],Test First ,[object Object]
Lots of little steps working towards a solution    Output  ,[object Object],[object Object]
Test Driven Development Development/Testing Phases Stubs Domain Model User Stories Behaviour Driven Development GUI Testing Fitness User Acceptance Test Unit & Component Test Mocks Implemented Behaviour System Integration Test No Mocks /Stubs Deployment Verification Test

More Related Content

What's hot

Practices and Tools for Building Better APIs
Practices and Tools for Building Better APIsPractices and Tools for Building Better APIs
Practices and Tools for Building Better APIs
Peter Hendriks
 
Zend Studio Tips and Tricks
Zend Studio Tips and TricksZend Studio Tips and Tricks
Zend Studio Tips and TricksRoy Ganor
 
Testing Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation FrameworksTesting Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation Frameworks
Łukasz Morawski
 
PHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for BeginnersPHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for Beginners
Adam Englander
 
Modern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design PatternsModern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design Patterns
Volodymyr Voytyshyn
 
...and thus your forms automagically disappeared
...and thus your forms automagically disappeared...and thus your forms automagically disappeared
...and thus your forms automagically disappearedLuc Bors
 
Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)
Peter Hendriks
 
Jug Guice Presentation
Jug Guice PresentationJug Guice Presentation
Jug Guice PresentationDmitry Buzdin
 
Dependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony ContainerDependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony Container
Diego Lewin
 
Go f designpatterns 130116024923-phpapp02
Go f designpatterns 130116024923-phpapp02Go f designpatterns 130116024923-phpapp02
Go f designpatterns 130116024923-phpapp02
Jagath Bandara Senanayaka
 
[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android
Hazem Saleh
 
Google Guice
Google GuiceGoogle Guice
Google Guice
Andriy Andrunevchyn
 
Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010
Lars Vogel
 
CDI @javaonehyderabad
CDI @javaonehyderabadCDI @javaonehyderabad
CDI @javaonehyderabad
Prasad Subramanian
 
Flavours - Classic/Technical BDD
Flavours - Classic/Technical BDDFlavours - Classic/Technical BDD
Flavours - Classic/Technical BDD
David Harrison
 
Babble article - Test Automation & Text Translation
Babble article - Test Automation & Text TranslationBabble article - Test Automation & Text Translation
Babble article - Test Automation & Text Translation
David Harrison
 
Functional Dependency Injection in C#
Functional Dependency Injection in C#Functional Dependency Injection in C#
Functional Dependency Injection in C#
Thomas Jaskula
 
Eclipse BPEL Designer
Eclipse BPEL DesignerEclipse BPEL Designer
Eclipse BPEL Designermilliger
 

What's hot (18)

Practices and Tools for Building Better APIs
Practices and Tools for Building Better APIsPractices and Tools for Building Better APIs
Practices and Tools for Building Better APIs
 
Zend Studio Tips and Tricks
Zend Studio Tips and TricksZend Studio Tips and Tricks
Zend Studio Tips and Tricks
 
Testing Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation FrameworksTesting Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation Frameworks
 
PHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for BeginnersPHPConf.asia 2016 - BDD with Behat for Beginners
PHPConf.asia 2016 - BDD with Behat for Beginners
 
Modern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design PatternsModern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design Patterns
 
...and thus your forms automagically disappeared
...and thus your forms automagically disappeared...and thus your forms automagically disappeared
...and thus your forms automagically disappeared
 
Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)Practices and tools for building better API (JFall 2013)
Practices and tools for building better API (JFall 2013)
 
Jug Guice Presentation
Jug Guice PresentationJug Guice Presentation
Jug Guice Presentation
 
Dependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony ContainerDependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony Container
 
Go f designpatterns 130116024923-phpapp02
Go f designpatterns 130116024923-phpapp02Go f designpatterns 130116024923-phpapp02
Go f designpatterns 130116024923-phpapp02
 
[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android
 
Google Guice
Google GuiceGoogle Guice
Google Guice
 
Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010
 
CDI @javaonehyderabad
CDI @javaonehyderabadCDI @javaonehyderabad
CDI @javaonehyderabad
 
Flavours - Classic/Technical BDD
Flavours - Classic/Technical BDDFlavours - Classic/Technical BDD
Flavours - Classic/Technical BDD
 
Babble article - Test Automation & Text Translation
Babble article - Test Automation & Text TranslationBabble article - Test Automation & Text Translation
Babble article - Test Automation & Text Translation
 
Functional Dependency Injection in C#
Functional Dependency Injection in C#Functional Dependency Injection in C#
Functional Dependency Injection in C#
 
Eclipse BPEL Designer
Eclipse BPEL DesignerEclipse BPEL Designer
Eclipse BPEL Designer
 

Viewers also liked

Mpi.Net Talk
Mpi.Net TalkMpi.Net Talk
Mpi.Net Talk
willmation
 
Test Infected Presentation
Test Infected PresentationTest Infected Presentation
Test Infected Presentation
willmation
 
Post Sharp Talk
Post Sharp TalkPost Sharp Talk
Post Sharp Talk
willmation
 
10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience
Yuan Wang
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
In a Rocket
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media Plan
Post Planner
 

Viewers also liked (6)

Mpi.Net Talk
Mpi.Net TalkMpi.Net Talk
Mpi.Net Talk
 
Test Infected Presentation
Test Infected PresentationTest Infected Presentation
Test Infected Presentation
 
Post Sharp Talk
Post Sharp TalkPost Sharp Talk
Post Sharp Talk
 
10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience10 Insightful Quotes On Designing A Better Customer Experience
10 Insightful Quotes On Designing A Better Customer Experience
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media Plan
 

Similar to Behaviour Driven Development V 0.1

CucumberSeleniumWD
CucumberSeleniumWDCucumberSeleniumWD
CucumberSeleniumWDVikas Sarin
 
Bridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous DeliveryBridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous Delivery
masoodjan
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan
 
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual StudioSPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
NCCOMMS
 
ASP.NET 8 Developer Roadmap By ScholarHat PDF
ASP.NET 8 Developer Roadmap By ScholarHat PDFASP.NET 8 Developer Roadmap By ScholarHat PDF
ASP.NET 8 Developer Roadmap By ScholarHat PDF
Scholarhat
 
BDD with JBehave and Selenium
BDD with JBehave and SeleniumBDD with JBehave and Selenium
BDD with JBehave and Selenium
Nikolay Vasilev
 
Zend con 2016 bdd with behat for beginners
Zend con 2016   bdd with behat for beginnersZend con 2016   bdd with behat for beginners
Zend con 2016 bdd with behat for beginners
Adam Englander
 
Synchronized Development for Distributed Teams
Synchronized Development for Distributed TeamsSynchronized Development for Distributed Teams
Synchronized Development for Distributed Teams
Togakangaroo
 
Nitin_updated_Profile
Nitin_updated_ProfileNitin_updated_Profile
Nitin_updated_ProfileNitin Saxena
 
Spec flow – functional testing made easy
Spec flow – functional testing made easySpec flow – functional testing made easy
Spec flow – functional testing made easyPaul Stack
 
Coding Naked 2023
Coding Naked 2023Coding Naked 2023
Coding Naked 2023
Caleb Jenkins
 
Content Strategy and Developer Engagement for DevPortals
Content Strategy and Developer Engagement for DevPortalsContent Strategy and Developer Engagement for DevPortals
Content Strategy and Developer Engagement for DevPortals
Axway
 
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
Dave Bost
 
D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksSunil Patil
 
Bridging the gap between business and technology - Behaviour Driven Developme...
Bridging the gap between business and technology - Behaviour Driven Developme...Bridging the gap between business and technology - Behaviour Driven Developme...
Bridging the gap between business and technology - Behaviour Driven Developme...
marcin_pajdzik
 
BDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User StoriesBDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User Stories
Sauce Labs
 

Similar to Behaviour Driven Development V 0.1 (20)

CucumberSeleniumWD
CucumberSeleniumWDCucumberSeleniumWD
CucumberSeleniumWD
 
Bridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous DeliveryBridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous Delivery
 
Drupal 7 ci and testing
Drupal 7 ci and testingDrupal 7 ci and testing
Drupal 7 ci and testing
 
Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2Daniel Egan Msdn Tech Days Oc Day2
Daniel Egan Msdn Tech Days Oc Day2
 
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual StudioSPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
SPCA2013 - Test-driven Development with SharePoint 2013 and Visual Studio
 
ASP.NET 8 Developer Roadmap By ScholarHat PDF
ASP.NET 8 Developer Roadmap By ScholarHat PDFASP.NET 8 Developer Roadmap By ScholarHat PDF
ASP.NET 8 Developer Roadmap By ScholarHat PDF
 
BDD with JBehave and Selenium
BDD with JBehave and SeleniumBDD with JBehave and Selenium
BDD with JBehave and Selenium
 
JAX 08 - Agile RCP
JAX 08 - Agile RCPJAX 08 - Agile RCP
JAX 08 - Agile RCP
 
Tdd,Ioc
Tdd,IocTdd,Ioc
Tdd,Ioc
 
Zend con 2016 bdd with behat for beginners
Zend con 2016   bdd with behat for beginnersZend con 2016   bdd with behat for beginners
Zend con 2016 bdd with behat for beginners
 
Resume
ResumeResume
Resume
 
Synchronized Development for Distributed Teams
Synchronized Development for Distributed TeamsSynchronized Development for Distributed Teams
Synchronized Development for Distributed Teams
 
Nitin_updated_Profile
Nitin_updated_ProfileNitin_updated_Profile
Nitin_updated_Profile
 
Spec flow – functional testing made easy
Spec flow – functional testing made easySpec flow – functional testing made easy
Spec flow – functional testing made easy
 
Coding Naked 2023
Coding Naked 2023Coding Naked 2023
Coding Naked 2023
 
Content Strategy and Developer Engagement for DevPortals
Content Strategy and Developer Engagement for DevPortalsContent Strategy and Developer Engagement for DevPortals
Content Strategy and Developer Engagement for DevPortals
 
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
Shine a Light with Prism (the Composite Application Guidance for WPF and Silv...
 
D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source Frameworks
 
Bridging the gap between business and technology - Behaviour Driven Developme...
Bridging the gap between business and technology - Behaviour Driven Developme...Bridging the gap between business and technology - Behaviour Driven Developme...
Bridging the gap between business and technology - Behaviour Driven Developme...
 
BDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User StoriesBDD Selenium for Agile Teams - User Stories
BDD Selenium for Agile Teams - User Stories
 

Recently uploaded

Observation Lab PowerPoint Assignment for TEM 431
Observation Lab PowerPoint Assignment for TEM 431Observation Lab PowerPoint Assignment for TEM 431
Observation Lab PowerPoint Assignment for TEM 431
ecamare2
 
Digital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and TemplatesDigital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and Templates
Aurelien Domont, MBA
 
Top mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptxTop mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptx
JeremyPeirce1
 
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.docBài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
daothibichhang1
 
Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024
Kirill Klimov
 
Auditing study material for b.com final year students
Auditing study material for b.com final year  studentsAuditing study material for b.com final year  students
Auditing study material for b.com final year students
narasimhamurthyh4
 
VAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and RequirementsVAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and Requirements
uae taxgpt
 
Exploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social DreamingExploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social Dreaming
Nicola Wreford-Howard
 
Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024
FelixPerez547899
 
ModelingMarketingStrategiesMKS.CollumbiaUniversitypdf
ModelingMarketingStrategiesMKS.CollumbiaUniversitypdfModelingMarketingStrategiesMKS.CollumbiaUniversitypdf
ModelingMarketingStrategiesMKS.CollumbiaUniversitypdf
fisherameliaisabella
 
LA HUG - Video Testimonials with Chynna Morgan - June 2024
LA HUG - Video Testimonials with Chynna Morgan - June 2024LA HUG - Video Testimonials with Chynna Morgan - June 2024
LA HUG - Video Testimonials with Chynna Morgan - June 2024
Lital Barkan
 
In the Adani-Hindenburg case, what is SEBI investigating.pptx
In the Adani-Hindenburg case, what is SEBI investigating.pptxIn the Adani-Hindenburg case, what is SEBI investigating.pptx
In the Adani-Hindenburg case, what is SEBI investigating.pptx
Adani case
 
Authentically Social Presented by Corey Perlman
Authentically Social Presented by Corey PerlmanAuthentically Social Presented by Corey Perlman
Authentically Social Presented by Corey Perlman
Corey Perlman, Social Media Speaker and Consultant
 
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
bosssp10
 
FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134
LR1709MUSIC
 
Agency Managed Advisory Board As a Solution To Career Path Defining Business ...
Agency Managed Advisory Board As a Solution To Career Path Defining Business ...Agency Managed Advisory Board As a Solution To Career Path Defining Business ...
Agency Managed Advisory Board As a Solution To Career Path Defining Business ...
Boris Ziegler
 
Sustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & EconomySustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & Economy
Operational Excellence Consulting
 
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challengesEvent Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Holger Mueller
 
Set off and carry forward of losses and assessment of individuals.pptx
Set off and carry forward of losses and assessment of individuals.pptxSet off and carry forward of losses and assessment of individuals.pptx
Set off and carry forward of losses and assessment of individuals.pptx
HARSHITHV26
 
The Influence of Marketing Strategy and Market Competition on Business Perfor...
The Influence of Marketing Strategy and Market Competition on Business Perfor...The Influence of Marketing Strategy and Market Competition on Business Perfor...
The Influence of Marketing Strategy and Market Competition on Business Perfor...
Adam Smith
 

Recently uploaded (20)

Observation Lab PowerPoint Assignment for TEM 431
Observation Lab PowerPoint Assignment for TEM 431Observation Lab PowerPoint Assignment for TEM 431
Observation Lab PowerPoint Assignment for TEM 431
 
Digital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and TemplatesDigital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and Templates
 
Top mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptxTop mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptx
 
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.docBài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
Bài tập - Tiếng anh 11 Global Success UNIT 1 - Bản HS.doc
 
Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024
 
Auditing study material for b.com final year students
Auditing study material for b.com final year  studentsAuditing study material for b.com final year  students
Auditing study material for b.com final year students
 
VAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and RequirementsVAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and Requirements
 
Exploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social DreamingExploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social Dreaming
 
Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024
 
ModelingMarketingStrategiesMKS.CollumbiaUniversitypdf
ModelingMarketingStrategiesMKS.CollumbiaUniversitypdfModelingMarketingStrategiesMKS.CollumbiaUniversitypdf
ModelingMarketingStrategiesMKS.CollumbiaUniversitypdf
 
LA HUG - Video Testimonials with Chynna Morgan - June 2024
LA HUG - Video Testimonials with Chynna Morgan - June 2024LA HUG - Video Testimonials with Chynna Morgan - June 2024
LA HUG - Video Testimonials with Chynna Morgan - June 2024
 
In the Adani-Hindenburg case, what is SEBI investigating.pptx
In the Adani-Hindenburg case, what is SEBI investigating.pptxIn the Adani-Hindenburg case, what is SEBI investigating.pptx
In the Adani-Hindenburg case, what is SEBI investigating.pptx
 
Authentically Social Presented by Corey Perlman
Authentically Social Presented by Corey PerlmanAuthentically Social Presented by Corey Perlman
Authentically Social Presented by Corey Perlman
 
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
 
FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134
 
Agency Managed Advisory Board As a Solution To Career Path Defining Business ...
Agency Managed Advisory Board As a Solution To Career Path Defining Business ...Agency Managed Advisory Board As a Solution To Career Path Defining Business ...
Agency Managed Advisory Board As a Solution To Career Path Defining Business ...
 
Sustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & EconomySustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & Economy
 
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challengesEvent Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
 
Set off and carry forward of losses and assessment of individuals.pptx
Set off and carry forward of losses and assessment of individuals.pptxSet off and carry forward of losses and assessment of individuals.pptx
Set off and carry forward of losses and assessment of individuals.pptx
 
The Influence of Marketing Strategy and Market Competition on Business Perfor...
The Influence of Marketing Strategy and Market Competition on Business Perfor...The Influence of Marketing Strategy and Market Competition on Business Perfor...
The Influence of Marketing Strategy and Market Competition on Business Perfor...
 

Behaviour Driven Development V 0.1

  • 1. Behaviour Driven Development With NBehave Linking User Stories and Domain Driven Design to Testing David Ross W: www.pebblesteps.com E: willmation@gmail.com
  • 2.
  • 3. Top down and Bottom up Testing
  • 4.
  • 5.
  • 6. Behavior Driven Development BDD is not: a testing framework or style of testing a method for writing tests BDD is: A formalised template for User Stories Able to create testable User Stories since they are defined in a formal manner Promotes “security” to a first call citizen in the analysis process
  • 7. Simple Trading application Excel spreadsheet replacement
  • 8. Allow Portfolio Manager to decide the percentage split between Cash, Property and Stock within the Portfolio Inform the Trader when the Portfolio needs to be rebalanced (ie split in the pie has changed significantly) Allow Operations to standardise Portfolio names Simple Trading application Requirements
  • 9.
  • 10.
  • 11. Test First DevelopmentHow easy is it to use TFD for the following Requirement/Story Value = Units * Market Price Increase the performance of the User Security module by automatically caching the user’s manager Id The system must email the Portfolio manager when the Portfolio needs to be rebalanced Build a web site so that customers can see the performance of the portfolio
  • 12. Test First DevelopmentDo you feel guilty?? Do you write a Failing unit test before every piece of code? Do you write a line of Unit Test code for EVERY line of production code?
  • 13. Behavior Driven How do you write a test when you don’t know where you are going? Maybe we need requirements that are easy to write tests for?
  • 14. RequirementsWhat are they Describes what a system should do but not how it will be done Contract between the implementation team and the analysis team Audience is typically the stake holders and not the development team
  • 15.
  • 17.
  • 18. BDD User StoriesFormal template for User Stories Story Template As a [User/Role]I want [Behaviour]so that [I receive benefit] Example As a “Operations staff member”I want “To create a Portfolio”so that“So that it can be traded”
  • 19. BDD User StoriesFormal template for User Stories Scenario Template Given some initial context (the givens),When an event occurs,then ensure some outcomes. Example Given “New portfolio is called Balanced Fund”When “Portfolio already exists”then “Portfolio can no be created”
  • 20. .NET Library for writing automated BDD style tests Fluent syntax for building up a BDD Style User Stories Test runner that executes the stories and generates a report listing the contents of the stories NBehave What is it?
  • 21. Creating a BDD Theme Collection of related stories [Theme("Portfolio Maintenance")] public class PortfolioMaintenanceStory { [Story] public void portfolio_create_story () { ... } [Story] public void portfolio_delete_story() { ... } } Reference:NBehave.Narrator.Framework.dll
  • 22. Creating a Story Fluent interface to define the story var story = new Story("Create portfolio"); story.AsA(“Operations team member") .IWant("To create a new portfolio on behalf of a portfolio manager") .SoThat("the portfolio manager can configure the portfolio and the front office can trade");
  • 23. Creating a Scenario Fluent interface to define the story story.WithScenario("portfolio does not exist") .Given("portfolio name is $name", "Aggressive Fund") .When("portfolio does not exist in the database") .Then("new portfolio should be created"); story.WithScenario("portfolio already exists") .Given("portfolio name is $name", "Aggressive Fund") .When("portfolio already exists in database") .Then("an error should occur");
  • 24. Executing the test WithNBehave runner or mbUnit Ouch we get an error??? The scenario throws an exception – NBehave isn’t validating any code Use Pending story.WithScenario("portfolio does not exist") .Pending("In progress") .Given("portfolio name is $name", "Aggressive Fund") .When("portfolio does not exist in the database") .Then("new portfolio should be created");
  • 25. Behavior Driven Development Across the Project (Story) Life Cycle Story Pending Scenario Stubbed Behavior Cycle (Red, Green, Refactor) Real Behavior Cycle (Red, Green, Refactor) Acceptance Test
  • 26. Stubbing out the behavior WithNBehave and Rhino.Mocks Steps to generate an API Go through the User story and find all the domain objects Create a class for each domain object but don’t add state Go through the User story and create a find all the services that are required (Repositories etc) Create an interface for each service but don’t add any methods
  • 27. Steps to generate the API continued... Slowly implement the story Add domain object properties as required Add methods signatures as required Use Stubs to explore Inputs/Outputsto the methods Stubbing out the behavior WithNBehave and Mocking
  • 28. Stubbing example Create a new portfolio story stringportfolioName = ""; Portfoliop = null; varportfolioRepository = MockRepository.GenerateStub<IPortfolioRepository>(); varportfolioService = MockRepository.GenerateStub<IPortfolioService>(); s.WithScenario("portfolio already exists") .Given("portfolio name is $name", "Aggressive Fund", n => { portfolioName= n; p = new Portfolio { Name = portfolioName }; portfolioRepository. Stub(x => x.FindPortfolioByName(portfolioName)).Return(p); portfolioService. Stub(X => X.CreatePortfolio(p)).Throw(new ItemExistsException()); })
  • 29. Stubbing example Create a new portfolio story .When("portfolio already exists in database", () => Assert.IsNotNull( portfolioRepository.FindPortfolioByName(portfolioName)) ) .Then("new portfolio create should fail", () => Assert.Throws<ItemExistsException>(() => portfolioService.CreatePortfolio(p)) );
  • 30.
  • 31. Design starting with interfaces (using stubs)
  • 32.
  • 33.
  • 34. Test Driven Development Development/Testing Phases Stubs Domain Model User Stories Behaviour Driven Development GUI Testing Fitness User Acceptance Test Unit & Component Test Mocks Implemented Behaviour System Integration Test No Mocks /Stubs Deployment Verification Test
  • 35. Fixtures to Specifications Loosing Assert from tests. Easier to read? For BAs, yes... Assert.IsTrue(component.IsValid) component.IsValid.ShouldBeTrue() Assert.Contains(s, “hello world”); s.ShouldContains(“hello world”); NBehave contains extension methods for NUnit, mbUnit, xUnit
  • 36. Fixtures to Specifications Is it necessary? [TestFixture] [Context] [Test] [Specification] [Context] public class When_using_tokenized_stories { [Specification] public void should_replace_token_with_value() {} Stories for BDD. Specifications for focussed tests. The word Test has become a dirty word...
  • 37. Stories to documentation NBehave-Console.exe PebbleSteps.NBehave.Stories.dll /o stories.txt Theme: Trade Compliance Story: Pretrade compliance check As a Trader I want verify a trade against the portfolio before I call the broker So that the portfolio does not move out of compliance Scenario: trade will move portfolio out of compliance Given portfolio with name Balanced Fund And asset allocation pie contains segments Cash 0.4, Stock 0.3, Property 0.3 And allocation pie 0.05 And portfolio contains Stock IBM 1, Cash GBP 1, Property SW5 1Hb 1, Stock BHP 1 When market prices are IBM 1, GBP 1, SW5 1Hb 1, BHP 1 Then portfolio value is 4 And portfolio constituents are Stock totalValue:2 percentOfPie:0.5 lower:0.25 upper:0.35, Cash totalValue:1 percentOfPie:0.25 lower:0.35 upper:0.45, Property totalValue:1 percentOfPie:0.25 lower:0.25 upper:0.35, And portfolio is balanced
  • 38. MSBuild <UsingTask AssemblyFile="NBehave.MSBuild.dll" TaskName="NBehave.MSBuild.NBehaveTask" /> <NBehaveTask DryRun="false" FailBuild="false" StoryOutputPath="output.xml" TestAssemblies="PebbleSteps.NBehave.Stories.dll" />
  • 39. Still in beta… What’s left to do? The parameter regular expression is on [a-z][A-Z] $example0, $example1 – In story output first parameter is printed twice Gallio integration/replacement of current story runner Current story runner text output formatting is poor HTML or a XSLT for current XML output Occassional crash in the parsing engine that links text to delegate parameters
  • 40. More information http://nbehave.org/ http://www.codeplex.com/NBehave http://behaviour-driven.org/ http://dannorth.net/ Code will be placed onto www.pebblesteps.com Questions?

Editor's Notes

  1. Lets dive into TDD and TFD. The famous Red, Green, Green...
  2. Welcome everyone on this cold winter night. This is my first Winter in London so you will have to excuse my scarf and gloves...My name is David Ross and I will be presenting with Chris Roff.Tonight we will be introducing Test Driven Development.
  3. Lets dive into TDD and TFD. The famous Red, Green, Green...
  4. Lets dive into TDD and TFD. The famous Red, Green, Green...