SlideShare a Scribd company logo
Acceptance Test Driven Development  with SpecFlow and Friends Christopher Bartling Joel Levandoski
Contact information Christopher Bartling [email_address] Twitter:  @cbartling Joel Levandoski j [email_address] Twitter:  @joellevandoski
Administrative stuff Presentation and demo are available on BitBucket.org https://bitbucket.org/cebartling/ presentations
Topics Acceptance Test Driven Development (ATDD) SpecFlow for .NET Behavior Driven Development (BDD) tool WatiN and WebAii Live demonstration Questions
Acceptance Test Driven Development ATDD Acceptance tests are  executable specifications  of desired behavior and functionality of the system Expressed in language of the problem domain Automated Regression suite Development is driven from the  outside-in
ATDD vs. TDD TDD is extremely valuable, but you need more Achieve great unit test coverage and still not deliver value to the customer ATDD focuses on complete features and functionality ATDD: macro view  TDD: micro view
 
SpecFlow for .NET BDD testing framework Integrates nicely with Visual Studio Acceptance tests manifest themselves as features and scenarios SpecFlow generates automated test from features SpecFlow tests run as normal xUnit tests Visual Studio test runner, build server
Features Describe some piece of functionality of the system Maintained in a  .feature  file Plain readable text Understandable by all parties, including business  Gherkin format, popularized by Cucumber Features contain one or more scenarios
Feature file example Feature:  Calculate Net Present Value In order analyze the profitability of a project As a project manager I want to be able to calculate the project’s Net Present Value Scenario:  A project is rejected Given  a project to evaluate   When  data is entered reflecting a failing project ROI scenario   Then  the net present value calculator will reject the project
Scenarios A scenario describes a single acceptance test for a feature Most features are composed of multiple scenarios SpecFlow generates a test for each scenario The name of the test is generated from the scenario title
Scenario example Scenario:  A project is rejected when its NPV is    negative Given  a project to evaluate   When  data is entered reflecting a failing   ROI scenario   Then  the net present value calculator will   reject the project
Scenario steps Used to compose a scenario Custom code to automate your application Describe preconditions, triggering action, and verification of outputs for the acceptance test Given : preconditions When : triggering action Then : behavior and state verifications
Scenario step example Given   a project to evaluate is matched to the following step definition binding… [ Given ( @"a project to evaluate" )] public void GivenAProjectToEvaluate() { . . .  }
Set up and tear down Attributes for before and after events TestRun Feature Scenario, ScenarioBlock Step Specificity achieved when used with tags
Tags Markers that can be applied to features and scenarios  Useful for selectively mixing in behavior Used to categorize scenarios Some unit test frameworks support this categorization tagging Custom tags you define
Tag example @WatiN Scenario : Save valid sample size mid range Given  the user enters 10 as sample size When  the user selects save Then  the value is stored
Tag example used with BeforeScenario [ BeforeScenario (" WatiN ”)] public void BeforeScenarioUsingWatiN() { ... }
Background Common preconditions for all scenarios in a feature Contains one or more scenario steps  Executed before any other steps in the scenario SpecFlow generates a method from the background element in the feature file in the test class Invoked from each scenario test case in the test class
Background example Background : Given  that the welcome page is displayed Scenario : Add a comment to a book being    reviewed . . .
Scenario outlines Data-driven scenarios or scenario templates Consists of  Scenario template specification with data placeholders Set of examples providing values for placeholders SpecFlow generates parameterized test logic for the scenario outline and individual test method for each example set
Scenario outline example Scenario Outline : Score calculation tables Given  a new bowling game When  I roll the following series: < rolls > Then  my total score should be < total score > Examples :  |  game   |  rolls   |  total score  | | beginners game  | 2,7,3,4,1,1,5,1,1,1,1,1,1,1,1,1,1,1,5,1 | 40  | | one single spare | 2,8,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 | 29  |
ScenarioContext ScenarioContext.Current.Pending() Causes the step definition to return pending Used to signal a stubbed step definition ScenarioContext.Current  dictionary Allows you to carry context/state across step definitions participating in scenario
WatiN Open source browser automation tool for IE and Firefox Similar to Selenium, WebDriver, Watir Browser abstraction  Find elements using CSS selectors Interact with AJAX web elements Handle popup dialogs (native and HTML)
WebAii Browser automation tool from Telerik Automates both web 2.0 and Silverlight applications HTML element wrappers WaitForElement(s) support when using AJAX Identifying elements using LINQ Invoke JavaScript directly from test code
Best practices Write high-level specifications Specifications should remain stable over time Build a scripting interface for manipulating your system under test (SUT) Focus specifications on isolated behaviors Think of specifications in  Given-When-Then  format Use the Page Object pattern
Smells Specifications are constantly changing Specifications are composed of “sequential command executions” Specifications have a lot of instrumentation or fixture code Specification examples exhibit same structure
Net Present Value Calculator Demo Used in capital budgeting Measures the excess or shortfall of cash flows, in present value terms, once financing terms have been covered Demo has two implementations ASP.NET MVC Silverlight
Questions?
Literature cited http://www.concordion.org/Technique.html http://www.telerik.com/automated-testing-tools/webaii-framework- features.aspx http://watin.org / http://www.specflow.org / http://code.google.com/p/selenium/wiki/ PageObjects

More Related Content

PPTX
Behaviour Driven Development with SpecFlow
PDF
TDD and BDD and ATDD
PPTX
Bdd and spec flow
PPTX
Spec flow – functional testing made easy
KEY
ATDD in Practice
PDF
Behavior Driven Development with SpecFlow
PDF
NDC 2011 - SpecFlow: Pragmatic BDD for .NET
PPTX
Selenium + Specflow
Behaviour Driven Development with SpecFlow
TDD and BDD and ATDD
Bdd and spec flow
Spec flow – functional testing made easy
ATDD in Practice
Behavior Driven Development with SpecFlow
NDC 2011 - SpecFlow: Pragmatic BDD for .NET
Selenium + Specflow

What's hot (20)

KEY
Introduction to Acceptance Test Driven Development
PPTX
SpecFlow for Agile Teams
PDF
Spec(ing) Out Your Workflow with SpecFlow
PPTX
BDD for APIs
PDF
Test and Behaviour Driven Development (TDD/BDD)
PPTX
ATDD in practice
PPTX
SpecFlow Executable Specifications
PPTX
Using Specflow for BDD
PPTX
Automated Acceptance Tests in .NET
PPTX
TDD - Test Driven Development
PPTX
BDD presentation
PPTX
Unit Testing in Action - C#, NUnit, and Moq
PDF
TDD vs. ATDD - What, Why, Which, When & Where
PPTX
Agile and ATDD the perfect couple
PPTX
TDD & BDD
PPTX
Journey of atdd
PPT
Scrum and Test-driven development
PDF
Serenity-BDD training
PDF
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
PPTX
BDD with SpecFlow and Selenium
Introduction to Acceptance Test Driven Development
SpecFlow for Agile Teams
Spec(ing) Out Your Workflow with SpecFlow
BDD for APIs
Test and Behaviour Driven Development (TDD/BDD)
ATDD in practice
SpecFlow Executable Specifications
Using Specflow for BDD
Automated Acceptance Tests in .NET
TDD - Test Driven Development
BDD presentation
Unit Testing in Action - C#, NUnit, and Moq
TDD vs. ATDD - What, Why, Which, When & Where
Agile and ATDD the perfect couple
TDD & BDD
Journey of atdd
Scrum and Test-driven development
Serenity-BDD training
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
BDD with SpecFlow and Selenium
Ad

Viewers also liked (20)

PDF
Acceptance Test Driven Development
PDF
Introduction to Acceptance Test Driven Development
PPTX
Acceptance test driven development (attd) cycle
PPTX
CloudSpokes Overview
PPTX
Specflow - Criando uma ponte entre desenvolvedores.
PDF
Acceptance Test Driven Development at StarWest 2014
PDF
Agile Acceptance testing with Fitnesse
PPTX
Writing Acceptance Tests Using Fitnesse
PDF
How To Fit Testing Into The Iteration
PPT
Writing Effective User Stories
PDF
Acceptance Criteria with SpecFlow
PDF
Tech talk specflow_bddx_hassa_nagy
PDF
Cross mobile testautomation mit Xamarin & SpecFlow
PDF
ATDD Using Robot Framework
KEY
Writing GREAT Agile User Stories
PDF
ATDD - Acceptance Test Driven Development
KEY
Writing Effective User Stories
PPTX
Agile User Stories
PDF
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
PDF
Rt acceptance criteria by zas
Acceptance Test Driven Development
Introduction to Acceptance Test Driven Development
Acceptance test driven development (attd) cycle
CloudSpokes Overview
Specflow - Criando uma ponte entre desenvolvedores.
Acceptance Test Driven Development at StarWest 2014
Agile Acceptance testing with Fitnesse
Writing Acceptance Tests Using Fitnesse
How To Fit Testing Into The Iteration
Writing Effective User Stories
Acceptance Criteria with SpecFlow
Tech talk specflow_bddx_hassa_nagy
Cross mobile testautomation mit Xamarin & SpecFlow
ATDD Using Robot Framework
Writing GREAT Agile User Stories
ATDD - Acceptance Test Driven Development
Writing Effective User Stories
Agile User Stories
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Rt acceptance criteria by zas
Ad

Similar to Acceptance Test Driven Development With Spec Flow And Friends (20)

PPTX
Acceptance Test Driven Development
PDF
TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012
DOC
Testing Process
PPTX
Behavior Driven Development
PPTX
Bdd with Visual Studio 2010, Spec Flow and WatiN
PDF
Implement BDD with Cucumber and SpecFlow
PPTX
Web automation in BDD
PPTX
Free from the shackles of TDD
PDF
Behavior Driven Testing with SpecFlow
PDF
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
PPTX
Test automation, agile testing; dev ops summit hyderabad Bdd with cucumber
PDF
Behavior Driven Development - WPC 2011
DOC
Testing
PDF
Growing Manual Testers into Automators
PDF
Specification-By-Example with Gherkin
PPTX
Introduction to Testing and TDD
PDF
Workshop: Behavior Driven Development - Deliver value by Naveen Kumar Singh
PPTX
.NET executable requirements
PPTX
Behaviour Driven Development V 0.1
PDF
Anand Bagmar - Behavior Driven Testing (BDT) in Agile
Acceptance Test Driven Development
TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012
Testing Process
Behavior Driven Development
Bdd with Visual Studio 2010, Spec Flow and WatiN
Implement BDD with Cucumber and SpecFlow
Web automation in BDD
Free from the shackles of TDD
Behavior Driven Testing with SpecFlow
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
Test automation, agile testing; dev ops summit hyderabad Bdd with cucumber
Behavior Driven Development - WPC 2011
Testing
Growing Manual Testers into Automators
Specification-By-Example with Gherkin
Introduction to Testing and TDD
Workshop: Behavior Driven Development - Deliver value by Naveen Kumar Singh
.NET executable requirements
Behaviour Driven Development V 0.1
Anand Bagmar - Behavior Driven Testing (BDT) in Agile

More from Christopher Bartling (12)

PDF
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
PDF
Acceptance Test-driven Development with Cucumber-jvm
PDF
JavaScript TDD with Jasmine and Karma
KEY
Building Tropo Apps with Grails
KEY
CoffeeScript By Example
PPT
Introduction To Grails
KEY
Cucumber, Cuke4Duke, and Groovy
PPTX
Test Driven In Groovy
KEY
iPhone OS: The Next Killer Platform
PDF
RESTful Web Services
PDF
Grails Overview
PDF
Rich Web Clients 20081118
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
Acceptance Test-driven Development with Cucumber-jvm
JavaScript TDD with Jasmine and Karma
Building Tropo Apps with Grails
CoffeeScript By Example
Introduction To Grails
Cucumber, Cuke4Duke, and Groovy
Test Driven In Groovy
iPhone OS: The Next Killer Platform
RESTful Web Services
Grails Overview
Rich Web Clients 20081118

Acceptance Test Driven Development With Spec Flow And Friends

  • 1. Acceptance Test Driven Development with SpecFlow and Friends Christopher Bartling Joel Levandoski
  • 2. Contact information Christopher Bartling [email_address] Twitter: @cbartling Joel Levandoski j [email_address] Twitter: @joellevandoski
  • 3. Administrative stuff Presentation and demo are available on BitBucket.org https://bitbucket.org/cebartling/ presentations
  • 4. Topics Acceptance Test Driven Development (ATDD) SpecFlow for .NET Behavior Driven Development (BDD) tool WatiN and WebAii Live demonstration Questions
  • 5. Acceptance Test Driven Development ATDD Acceptance tests are executable specifications of desired behavior and functionality of the system Expressed in language of the problem domain Automated Regression suite Development is driven from the outside-in
  • 6. ATDD vs. TDD TDD is extremely valuable, but you need more Achieve great unit test coverage and still not deliver value to the customer ATDD focuses on complete features and functionality ATDD: macro view TDD: micro view
  • 7.  
  • 8. SpecFlow for .NET BDD testing framework Integrates nicely with Visual Studio Acceptance tests manifest themselves as features and scenarios SpecFlow generates automated test from features SpecFlow tests run as normal xUnit tests Visual Studio test runner, build server
  • 9. Features Describe some piece of functionality of the system Maintained in a .feature file Plain readable text Understandable by all parties, including business Gherkin format, popularized by Cucumber Features contain one or more scenarios
  • 10. Feature file example Feature: Calculate Net Present Value In order analyze the profitability of a project As a project manager I want to be able to calculate the project’s Net Present Value Scenario: A project is rejected Given a project to evaluate When data is entered reflecting a failing project ROI scenario Then the net present value calculator will reject the project
  • 11. Scenarios A scenario describes a single acceptance test for a feature Most features are composed of multiple scenarios SpecFlow generates a test for each scenario The name of the test is generated from the scenario title
  • 12. Scenario example Scenario: A project is rejected when its NPV is negative Given a project to evaluate When data is entered reflecting a failing ROI scenario Then the net present value calculator will reject the project
  • 13. Scenario steps Used to compose a scenario Custom code to automate your application Describe preconditions, triggering action, and verification of outputs for the acceptance test Given : preconditions When : triggering action Then : behavior and state verifications
  • 14. Scenario step example Given a project to evaluate is matched to the following step definition binding… [ Given ( @&quot;a project to evaluate&quot; )] public void GivenAProjectToEvaluate() { . . . }
  • 15. Set up and tear down Attributes for before and after events TestRun Feature Scenario, ScenarioBlock Step Specificity achieved when used with tags
  • 16. Tags Markers that can be applied to features and scenarios Useful for selectively mixing in behavior Used to categorize scenarios Some unit test frameworks support this categorization tagging Custom tags you define
  • 17. Tag example @WatiN Scenario : Save valid sample size mid range Given the user enters 10 as sample size When the user selects save Then the value is stored
  • 18. Tag example used with BeforeScenario [ BeforeScenario (&quot; WatiN ”)] public void BeforeScenarioUsingWatiN() { ... }
  • 19. Background Common preconditions for all scenarios in a feature Contains one or more scenario steps Executed before any other steps in the scenario SpecFlow generates a method from the background element in the feature file in the test class Invoked from each scenario test case in the test class
  • 20. Background example Background : Given that the welcome page is displayed Scenario : Add a comment to a book being reviewed . . .
  • 21. Scenario outlines Data-driven scenarios or scenario templates Consists of Scenario template specification with data placeholders Set of examples providing values for placeholders SpecFlow generates parameterized test logic for the scenario outline and individual test method for each example set
  • 22. Scenario outline example Scenario Outline : Score calculation tables Given a new bowling game When I roll the following series: < rolls > Then my total score should be < total score > Examples : | game | rolls | total score | | beginners game | 2,7,3,4,1,1,5,1,1,1,1,1,1,1,1,1,1,1,5,1 | 40 | | one single spare | 2,8,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 | 29 |
  • 23. ScenarioContext ScenarioContext.Current.Pending() Causes the step definition to return pending Used to signal a stubbed step definition ScenarioContext.Current dictionary Allows you to carry context/state across step definitions participating in scenario
  • 24. WatiN Open source browser automation tool for IE and Firefox Similar to Selenium, WebDriver, Watir Browser abstraction Find elements using CSS selectors Interact with AJAX web elements Handle popup dialogs (native and HTML)
  • 25. WebAii Browser automation tool from Telerik Automates both web 2.0 and Silverlight applications HTML element wrappers WaitForElement(s) support when using AJAX Identifying elements using LINQ Invoke JavaScript directly from test code
  • 26. Best practices Write high-level specifications Specifications should remain stable over time Build a scripting interface for manipulating your system under test (SUT) Focus specifications on isolated behaviors Think of specifications in Given-When-Then format Use the Page Object pattern
  • 27. Smells Specifications are constantly changing Specifications are composed of “sequential command executions” Specifications have a lot of instrumentation or fixture code Specification examples exhibit same structure
  • 28. Net Present Value Calculator Demo Used in capital budgeting Measures the excess or shortfall of cash flows, in present value terms, once financing terms have been covered Demo has two implementations ASP.NET MVC Silverlight
  • 30. Literature cited http://www.concordion.org/Technique.html http://www.telerik.com/automated-testing-tools/webaii-framework- features.aspx http://watin.org / http://www.specflow.org / http://code.google.com/p/selenium/wiki/ PageObjects