SlideShare a Scribd company logo
GTC-NL-FXD Rachid Kherazi
Behavior Driven Testing (BDT)
with MS VS2010 & SpecFlow
Confidential
GTC-NL for internal use
Goal of presentation
• Informative
• Share my knowledge w.r.t. Testing and Test tools
In the scope of “did you know?”
Gathered in my daily train trips
Amstelveen Best
Confidential
GTC-NL for internal use
Qeustion 1: what are the following two vegetables?
Subject of today is related to some vegetables
Answer 1: Cucumber Gherkin
Question 2: What is the difference between the two?
Answer 2:
Cucumber: Tool, behavior driven development, …
Gherkin: Language, Business Readable, Domain Specific Language,..
Let start with a Quiz
Confidential
GTC-NL for internal use
Content
• Behavior Driven Development (Development view)
– Agile Iteration and Test Driven Development (TDD)
– What’s all these DD’s? (TFD, TDD, BDD, ATDD and SDD)
– Scenario/Story and Gherkin-syntax
– Executable Specification
– Behavior Driven Development tools
– Live demo with SpecFlow
• Behavior Driven Testing (Test view)
– DDB vs BDT
Confidential
GTC-NL for internal use
http://www.synerzip.com/agile-method.htm
Introduction: Agile iterations and TTD
Confidential
GTC-NL for internal use
ATDD
- Acceptance Test Driven
- Different than BDD?
- Start with the acceptance test
- Examples,
(2) Write the
implementation code to
make the test pass. Keep
it simple
(3) Change the code to
remove duplication in code
and to improve the design
while ensuring that all tests
still pass.
(1) Imagine how the new
code should be called and
write the test as if the code
already existed
Confidential
GTC-NL for internal use
What are the advantages of TDD?
• TDD shortens the programming feedback loop
• TDD provides detailed specification (tests)
• TDD promotes the development of high-quality code
• TDD provides concrete evidence that your software works
• TDD supports evolutionary development
• TDD encourages developers to write code that is easily tested
TDD is used in
Agile development
eXtreme programming
Confidential
GTC-NL for internal use
ATDD
- Acceptance Test Driven
- Different than BDD?
- Start with the acceptance test
- Examples,
Test First
Development
Refactor
TDD
Start from acceptation test
Focus on behavior of feature
S/BDD
Confidential
GTC-NL for internal use
What’s all these DD’s?
TFD Test First Development
TDD Test Driven Development
ATDD Acceptance Test Driven Development
BDD Behavior Driven Development
STDD Story Test Driven Development
TTD = Test First Development + Refactor (remove duplicate, improve design)
Micro view
ATDD start for end user acceptance test
Macro view
BDD focus on the behavior of the feature
Based on user story: a couple of examples on how SUT could be used
Story written in a standard syntax: e.g. Given / When / Then
The [Given, When, Then] syntax is called Gherkin
First create test (Failing test) than create implementation (Test passed)
Given [initial context]
When [event]
Then [an outcome]
Subsequent steps of the same kind can also be specified with the “And “ and “But” keyword
Variations on a Theme
Context
Specification
AAA
User Story
Structure
Establish
Initial Context
Given
Arrange
SetContext
Interact with
SUT
When
Act
BecauseOf
Check the
results
Then
Assert
ItShould
Confidential
GTC-NL for internal use
Example: Application Under Test
(3) Application displays “Hello Best Tester: Password is Correct”
(If password = “Rachid”)
(1) type password “Rachid”
(2) press Login button
(0) start application
“Say Hello Best Tester” a simple application for demo purpose.
According req. of this tool: “Rachid”, “Ali” and ‘Pieter” are correct passwords for login.
Confidential
GTC-NL for internal use
Example: Feature file (Scenario’s: Given When Then)
Feature: Log-In in “Best Tester Application”, check correctness of
password
Scenario: Check Login with correct password
Given Application is started
When correct password is typed
And Login button is pressed
Then Login should be successful
And Messagebox should display "Hello Best Tester: Password Correct"
Describe some piece of functionality of the system
Plain readable text
Features contain one or more scenarios
A scenario describes a single acceptance test for a feature
Most features are composed of multiple scenarios
Tool generates a test for each scenario
The name of the test is generated from the scenario title
Confidential
GTC-NL for internal use
When scenario/story is in place it would be wonderful if there is a
tool that can run this scenario’s to verify that the implementation
actually behaves as specified.
Executable specification that verifies that the implementation behaves as expected, readable by all in the team, and around it
Requirements
/Behavior
In well known
format
e.g.
Given/When/Then
Tool
Implementation
(SUT)
Main benefit
Main benefit is not in the tool!
The benefit is that team get together and write down a common,
shared knowledge in a well known format. In one place.
Confidential
GTC-NL for internal use
Tools
This was the idea of Cucumber tool that first was created in the Ruby-community.
Cucumber can execute scenarios written in the Given/When/Then-syntax.
For .Net framework SpecFlow is known good tool.
Both tools used Gherkin syntax and are free (open source).
Cucumber
Ruby
SpecFlow
.Net
Confidential
GTC-NL for internal use
Behavior Driven Development in one slide
Feature file
(Scenario’s: Given When Then)
Test class (for Nunit)
Generated by SpecFow tool (.cs)
Stepper class
binding with implementation (.cs)
Implementation
(.dll, .exe)
Nunit dll
Nunit
Test
report
Code of Implementation (.cs)
Visual Studio 2010 + SpecFlow
SW developer
Requirements
User
feedback1
2
3
4
5
6
7
8
Confidential
GTC-NL for internal use
Some handy Attributes
Background
With the keyword background you can run some steps before each scenario in the
feature.
Hooks
Hooks are events that is fired in the following order.
And you can “hook in” code here to do useful things:
- Restore a database
- Dump a log on error
- Init variables before steps
Scenario outlines
Data-driven scenarios or scenario templates
Consists of Scenario template specification with data placeholders
Tool generates parameterized test logic for the scenario outline and individual test
method for each example set (using pairwise testing)
Confidential
GTC-NL for internal use
Some handy Attributes
Tag
Can be used to specify “categories” for Nunit or other test runners
e.g. @RegressionTestSet
@ignore tag is a special tag “ignore test”
# is reserved for comment
#language
The language of the feature files can be either specified globally in the
configuration file or in the header of the feature file using “#language” keyword
different ISO languages are supported
Debugging Tests
SpecFlow Visual Studio integration also supports debugging the execution of the
tests. Just like in the source code files of your project, you can also place
breakpoints in the SpecFlow feature files. Whenever you execute the generated
tests in debug mode, the execution will stop at the specified breakpoints and you
can execute the steps one-by-one using the standard “Step Over” (F10)
command or you can go to the detailed execution of the bindings using the “Step
Into” (F11) command.
Confidential
GTC-NL for internal use
SpecFlow configuration file
language
Test runner
Stop at error
Confidential
GTC-NL for internal use
Live demo “SayHello Application”
VS 2010 and SpecFlow Link Nunitdll
Confidential
GTC-NL for internal use
SpecFlow and generated Test Results
SpecFlow tool generates clear and concise report
Report
Confidential
GTC-NL for internal use
Behavior Driven Development in one slide
Feature file
(Scenario’s: Given When Then)
Test class (for Nunit)
Generated by SpecFow tool (.cs)
Stepper class
binding with implementation (.cs)
Implementation
(.dll, .exe)
Nunit dll
Nunit
Test
report
Code of Implementation (.cs)
Visual Studio 2010 + SpecFlow
SW developer
Requirements
User
feedback1
2
3
4
5
6
7
8
Confidential
GTC-NL for internal use
Behavior Driven Testing in one slide
Feature file
(Scenario’s: Given When Then)
Test class (for Nunit)
Generated by SpecFow tool (.cs)
Stepper class
binding with implementation (.cs)
SUT (FlashLite)
Nunit dll
Bello/Nunit
Test
report
Visual Studio 2010 + SpecFlow
Requirements
Tester SW/FW developer
implementation
code
Development
environment
User
SW/FW Implementation
feedback
4
2
3
1
5
Confidential
GTC-NL for internal use
http://www.synerzip.com/agile-method.htm
Behavior driven testing
Development domain
Test domain
Confidential
GTC-NL for internal use
BDD vs BDT
• Behavior Driven Development (BDD)
– Development domain
– White box
– Micro view
– Input = specification (Behavior)
– Output = Implementation
• Behavior Driven Testing (BDT)
– Test domain
– Black box (interface)
– Macro view
– Input = Specification (Behavior)
– Output = Test
Confidential
GTC-NL for internal use
Requirement Based Testing in one slide
Feature file
(Scenario’s: Given When Then)
Test class (for Nunit)
Generated by SpecFow tool (.cs)
Stepper class
binding with implementation (.cs)
SUT (FlashLite)
Nunit dll
Bello/Nunit
Test
report
Visual Studio 2010 + SpecFlow
Requirements
doc
SW/FW developer
implementation
code
Development
environment
User
SW/FW Implementation
feedback
4
3
2
1
5
Spec.doc to Feature file
convertor
(2) = refactor= clean up and improveTester
To be
developed
Confidential
GTC-NL for internal use
Learn more about SpecFlow and BDD
http://blog.dannorth.net/introducing-bdd/
http://www.specflow.org/
https://github.com/techtalk/SpecFlow
http://github.com/techtalk/SpecFlow-Examples
http://github.com/aslakhellesoy/cucumber/wiki
http://www.marcusoft.net/search/label/SpecFlow
https://github.com/marcushammarberg/
https://www.marcusoft.net
Free downloadable book
Confidential
GTC-NL for internal use
1, 2, 3
Given
When
Then
[TestMethod]
public void
Total_Should_Be_1_When_1_Product_Added()
{
var cart = new ShoppingCart("TEST");
cart.AddItem(new Product("SKU"));
Assert.AreEqual(1, cart.TotalItems);
}

More Related Content

What's hot (20)

PPT
TDD And Refactoring
Naresh Jain
 
PDF
An Introduction to Test Driven Development
CodeOps Technologies LLP
 
PDF
Cucumber spec - a tool takes your bdd to the next level
nextbuild
 
PDF
Test Driven Development (TDD)
David Ehringer
 
PPT
TDD (Test Driven Design)
nedirtv
 
DOCX
Test driven development and unit testing with examples in C++
Hong Le Van
 
PDF
TDD and BDD and ATDD
Anuar Nurmakanov
 
PPTX
Automation and Technical Debt
IBM UrbanCode Products
 
PPTX
TDD - Agile
harinderpisces
 
PPT
Scrum and Test-driven development
toteb5
 
PPTX
Model-Based Testing: Theory and Practice. Keynote @ MoTiP (ISSRE) 2012.
Wolfgang Grieskamp
 
PDF
Unit testing legacy code
Lars Thorup
 
PPT
Test Driven Development
Sachithra Gayan
 
PPTX
Software Quality via Unit Testing
Shaun Abram
 
PPTX
Test-Driven Development
John Blum
 
PPTX
TDD - Test Driven Development
Tung Nguyen Thanh
 
PDF
Agile Programming Systems # TDD intro
Vitaliy Kulikov
 
PDF
Using task models in model-based testing
Rachid Kherrazi
 
KEY
Unit Testing Your Application
Paladin Web Services
 
PDF
Test Driven iOS Development (TDD)
Babul Mirdha
 
TDD And Refactoring
Naresh Jain
 
An Introduction to Test Driven Development
CodeOps Technologies LLP
 
Cucumber spec - a tool takes your bdd to the next level
nextbuild
 
Test Driven Development (TDD)
David Ehringer
 
TDD (Test Driven Design)
nedirtv
 
Test driven development and unit testing with examples in C++
Hong Le Van
 
TDD and BDD and ATDD
Anuar Nurmakanov
 
Automation and Technical Debt
IBM UrbanCode Products
 
TDD - Agile
harinderpisces
 
Scrum and Test-driven development
toteb5
 
Model-Based Testing: Theory and Practice. Keynote @ MoTiP (ISSRE) 2012.
Wolfgang Grieskamp
 
Unit testing legacy code
Lars Thorup
 
Test Driven Development
Sachithra Gayan
 
Software Quality via Unit Testing
Shaun Abram
 
Test-Driven Development
John Blum
 
TDD - Test Driven Development
Tung Nguyen Thanh
 
Agile Programming Systems # TDD intro
Vitaliy Kulikov
 
Using task models in model-based testing
Rachid Kherrazi
 
Unit Testing Your Application
Paladin Web Services
 
Test Driven iOS Development (TDD)
Babul Mirdha
 

Viewers also liked (20)

PDF
Behavior Driven Development (BDD)
Ajay Danait
 
PPTX
Orthogonal array
ATUL RANJAN
 
PPTX
Spec flow – functional testing made easy
Paul Stack
 
PPT
What Is Dfss
NCNarayanan
 
PPTX
Implimentation of Taguchi method on CNC EDM and CNC WEDM
kiranhg
 
PPTX
Design of Experiment (DOE): Taguchi Method and Full Factorial Design in Surfa...
Ahmad Syafiq
 
PDF
Application of Design of Experiments (DOE) using Dr.Taguchi -Orthogonal Array...
Karthikeyan Kannappan
 
PPT
Taguchi presentation
bwyrwa
 
PDF
BDD in Action – principles, practices and real-world application
John Ferguson Smart Limited
 
PPTX
BDD presentation
temebele
 
PPT
Taguchi method
Mentari Pagi
 
PPT
Behavior Driven Development (BDD) and Agile Testing
dversaci
 
PDF
Test and Behaviour Driven Development (TDD/BDD)
Lars Thorup
 
PDF
Behavior Driven Development with Cucumber
Brandon Keepers
 
PDF
BTXA part 4 of 5
justmargie
 
PDF
Thesis1 final
alimac326
 
PPT
Absence2
Sheila A
 
PPTX
Living things maria moya
lola caravaca
 
PPT
A Little Piece of Lincolnshire
Ancestry Central
 
PDF
Changing planet interview
gorin2008
 
Behavior Driven Development (BDD)
Ajay Danait
 
Orthogonal array
ATUL RANJAN
 
Spec flow – functional testing made easy
Paul Stack
 
What Is Dfss
NCNarayanan
 
Implimentation of Taguchi method on CNC EDM and CNC WEDM
kiranhg
 
Design of Experiment (DOE): Taguchi Method and Full Factorial Design in Surfa...
Ahmad Syafiq
 
Application of Design of Experiments (DOE) using Dr.Taguchi -Orthogonal Array...
Karthikeyan Kannappan
 
Taguchi presentation
bwyrwa
 
BDD in Action – principles, practices and real-world application
John Ferguson Smart Limited
 
BDD presentation
temebele
 
Taguchi method
Mentari Pagi
 
Behavior Driven Development (BDD) and Agile Testing
dversaci
 
Test and Behaviour Driven Development (TDD/BDD)
Lars Thorup
 
Behavior Driven Development with Cucumber
Brandon Keepers
 
BTXA part 4 of 5
justmargie
 
Thesis1 final
alimac326
 
Absence2
Sheila A
 
Living things maria moya
lola caravaca
 
A Little Piece of Lincolnshire
Ancestry Central
 
Changing planet interview
gorin2008
 
Ad

Similar to Behavior Driven Testing with SpecFlow (20)

PDF
TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012
Tieturi Oy
 
PPTX
CucumberSeleniumWD
Vikas Sarin
 
PPT
Behavior Driven Development by Example
Nalin Goonawardana
 
PPTX
PHPConf.asia 2016 - BDD with Behat for Beginners
Adam Englander
 
PPTX
Tdd is not about testing (C++ version)
Gianluca Padovani
 
PPTX
BDD using Cucumber JVM
Vijay Krishnan Ramaswamy
 
PPTX
Test Driven Development (TDD) Preso 360|Flex 2010
guest5639fa9
 
PPTX
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Elad Elrom
 
PDF
Automated Developer Testing: Achievements and Challenges
Tao Xie
 
PPTX
Zend con 2016 bdd with behat for beginners
Adam Englander
 
PPT
Manual testing visonia
VisoniaTechlab
 
DOCX
Resume_shai.docx
Shaista Fatima
 
PPTX
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Ukraine
 
PPT
Susan windsor soft test 16th november 2005
David O'Dowd
 
PPTX
Tdd is not about testing (OOP)
Gianluca Padovani
 
PDF
Katalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio
 
PDF
Testing apps with MTM and Tea Foundation Service
Kevin DeRudder
 
PPTX
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012
Tieturi Oy
 
CucumberSeleniumWD
Vikas Sarin
 
Behavior Driven Development by Example
Nalin Goonawardana
 
PHPConf.asia 2016 - BDD with Behat for Beginners
Adam Englander
 
Tdd is not about testing (C++ version)
Gianluca Padovani
 
BDD using Cucumber JVM
Vijay Krishnan Ramaswamy
 
Test Driven Development (TDD) Preso 360|Flex 2010
guest5639fa9
 
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Elad Elrom
 
Automated Developer Testing: Achievements and Challenges
Tao Xie
 
Zend con 2016 bdd with behat for beginners
Adam Englander
 
Manual testing visonia
VisoniaTechlab
 
Resume_shai.docx
Shaista Fatima
 
GlobalLogic Test Automation Online TechTalk “Test Driven Development as a Per...
GlobalLogic Ukraine
 
Susan windsor soft test 16th november 2005
David O'Dowd
 
Tdd is not about testing (OOP)
Gianluca Padovani
 
Katalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio
 
Testing apps with MTM and Tea Foundation Service
Kevin DeRudder
 
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
Ad

Recently uploaded (20)

PPTX
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
PPTX
From spreadsheets and delays to real-time control
SatishKumar2651
 
PDF
Salesforce Experience Cloud Consultant.pdf
VALiNTRY360
 
PPTX
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 
PPTX
UI5con_2025_Accessibility_Ever_Evolving_
gerganakremenska1
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PPTX
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
Why is partnering with a SaaS development company crucial for enterprise succ...
Nextbrain Technologies
 
PDF
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
PPTX
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
From spreadsheets and delays to real-time control
SatishKumar2651
 
Salesforce Experience Cloud Consultant.pdf
VALiNTRY360
 
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 
UI5con_2025_Accessibility_Ever_Evolving_
gerganakremenska1
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Why is partnering with a SaaS development company crucial for enterprise succ...
Nextbrain Technologies
 
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 

Behavior Driven Testing with SpecFlow

  • 1. GTC-NL-FXD Rachid Kherazi Behavior Driven Testing (BDT) with MS VS2010 & SpecFlow
  • 2. Confidential GTC-NL for internal use Goal of presentation • Informative • Share my knowledge w.r.t. Testing and Test tools In the scope of “did you know?” Gathered in my daily train trips Amstelveen Best
  • 3. Confidential GTC-NL for internal use Qeustion 1: what are the following two vegetables? Subject of today is related to some vegetables Answer 1: Cucumber Gherkin Question 2: What is the difference between the two? Answer 2: Cucumber: Tool, behavior driven development, … Gherkin: Language, Business Readable, Domain Specific Language,.. Let start with a Quiz
  • 4. Confidential GTC-NL for internal use Content • Behavior Driven Development (Development view) – Agile Iteration and Test Driven Development (TDD) – What’s all these DD’s? (TFD, TDD, BDD, ATDD and SDD) – Scenario/Story and Gherkin-syntax – Executable Specification – Behavior Driven Development tools – Live demo with SpecFlow • Behavior Driven Testing (Test view) – DDB vs BDT
  • 5. Confidential GTC-NL for internal use http://www.synerzip.com/agile-method.htm Introduction: Agile iterations and TTD
  • 6. Confidential GTC-NL for internal use ATDD - Acceptance Test Driven - Different than BDD? - Start with the acceptance test - Examples, (2) Write the implementation code to make the test pass. Keep it simple (3) Change the code to remove duplication in code and to improve the design while ensuring that all tests still pass. (1) Imagine how the new code should be called and write the test as if the code already existed
  • 7. Confidential GTC-NL for internal use What are the advantages of TDD? • TDD shortens the programming feedback loop • TDD provides detailed specification (tests) • TDD promotes the development of high-quality code • TDD provides concrete evidence that your software works • TDD supports evolutionary development • TDD encourages developers to write code that is easily tested TDD is used in Agile development eXtreme programming
  • 8. Confidential GTC-NL for internal use ATDD - Acceptance Test Driven - Different than BDD? - Start with the acceptance test - Examples, Test First Development Refactor TDD Start from acceptation test Focus on behavior of feature S/BDD
  • 9. Confidential GTC-NL for internal use What’s all these DD’s? TFD Test First Development TDD Test Driven Development ATDD Acceptance Test Driven Development BDD Behavior Driven Development STDD Story Test Driven Development TTD = Test First Development + Refactor (remove duplicate, improve design) Micro view ATDD start for end user acceptance test Macro view BDD focus on the behavior of the feature Based on user story: a couple of examples on how SUT could be used Story written in a standard syntax: e.g. Given / When / Then The [Given, When, Then] syntax is called Gherkin First create test (Failing test) than create implementation (Test passed)
  • 10. Given [initial context] When [event] Then [an outcome] Subsequent steps of the same kind can also be specified with the “And “ and “But” keyword
  • 11. Variations on a Theme Context Specification AAA User Story Structure Establish Initial Context Given Arrange SetContext Interact with SUT When Act BecauseOf Check the results Then Assert ItShould
  • 12. Confidential GTC-NL for internal use Example: Application Under Test (3) Application displays “Hello Best Tester: Password is Correct” (If password = “Rachid”) (1) type password “Rachid” (2) press Login button (0) start application “Say Hello Best Tester” a simple application for demo purpose. According req. of this tool: “Rachid”, “Ali” and ‘Pieter” are correct passwords for login.
  • 13. Confidential GTC-NL for internal use Example: Feature file (Scenario’s: Given When Then) Feature: Log-In in “Best Tester Application”, check correctness of password Scenario: Check Login with correct password Given Application is started When correct password is typed And Login button is pressed Then Login should be successful And Messagebox should display "Hello Best Tester: Password Correct" Describe some piece of functionality of the system Plain readable text Features contain one or more scenarios A scenario describes a single acceptance test for a feature Most features are composed of multiple scenarios Tool generates a test for each scenario The name of the test is generated from the scenario title
  • 14. Confidential GTC-NL for internal use When scenario/story is in place it would be wonderful if there is a tool that can run this scenario’s to verify that the implementation actually behaves as specified. Executable specification that verifies that the implementation behaves as expected, readable by all in the team, and around it Requirements /Behavior In well known format e.g. Given/When/Then Tool Implementation (SUT) Main benefit Main benefit is not in the tool! The benefit is that team get together and write down a common, shared knowledge in a well known format. In one place.
  • 15. Confidential GTC-NL for internal use Tools This was the idea of Cucumber tool that first was created in the Ruby-community. Cucumber can execute scenarios written in the Given/When/Then-syntax. For .Net framework SpecFlow is known good tool. Both tools used Gherkin syntax and are free (open source). Cucumber Ruby SpecFlow .Net
  • 16. Confidential GTC-NL for internal use Behavior Driven Development in one slide Feature file (Scenario’s: Given When Then) Test class (for Nunit) Generated by SpecFow tool (.cs) Stepper class binding with implementation (.cs) Implementation (.dll, .exe) Nunit dll Nunit Test report Code of Implementation (.cs) Visual Studio 2010 + SpecFlow SW developer Requirements User feedback1 2 3 4 5 6 7 8
  • 17. Confidential GTC-NL for internal use Some handy Attributes Background With the keyword background you can run some steps before each scenario in the feature. Hooks Hooks are events that is fired in the following order. And you can “hook in” code here to do useful things: - Restore a database - Dump a log on error - Init variables before steps Scenario outlines Data-driven scenarios or scenario templates Consists of Scenario template specification with data placeholders Tool generates parameterized test logic for the scenario outline and individual test method for each example set (using pairwise testing)
  • 18. Confidential GTC-NL for internal use Some handy Attributes Tag Can be used to specify “categories” for Nunit or other test runners e.g. @RegressionTestSet @ignore tag is a special tag “ignore test” # is reserved for comment #language The language of the feature files can be either specified globally in the configuration file or in the header of the feature file using “#language” keyword different ISO languages are supported Debugging Tests SpecFlow Visual Studio integration also supports debugging the execution of the tests. Just like in the source code files of your project, you can also place breakpoints in the SpecFlow feature files. Whenever you execute the generated tests in debug mode, the execution will stop at the specified breakpoints and you can execute the steps one-by-one using the standard “Step Over” (F10) command or you can go to the detailed execution of the bindings using the “Step Into” (F11) command.
  • 19. Confidential GTC-NL for internal use SpecFlow configuration file language Test runner Stop at error
  • 20. Confidential GTC-NL for internal use Live demo “SayHello Application” VS 2010 and SpecFlow Link Nunitdll
  • 21. Confidential GTC-NL for internal use SpecFlow and generated Test Results SpecFlow tool generates clear and concise report Report
  • 22. Confidential GTC-NL for internal use Behavior Driven Development in one slide Feature file (Scenario’s: Given When Then) Test class (for Nunit) Generated by SpecFow tool (.cs) Stepper class binding with implementation (.cs) Implementation (.dll, .exe) Nunit dll Nunit Test report Code of Implementation (.cs) Visual Studio 2010 + SpecFlow SW developer Requirements User feedback1 2 3 4 5 6 7 8
  • 23. Confidential GTC-NL for internal use Behavior Driven Testing in one slide Feature file (Scenario’s: Given When Then) Test class (for Nunit) Generated by SpecFow tool (.cs) Stepper class binding with implementation (.cs) SUT (FlashLite) Nunit dll Bello/Nunit Test report Visual Studio 2010 + SpecFlow Requirements Tester SW/FW developer implementation code Development environment User SW/FW Implementation feedback 4 2 3 1 5
  • 24. Confidential GTC-NL for internal use http://www.synerzip.com/agile-method.htm Behavior driven testing Development domain Test domain
  • 25. Confidential GTC-NL for internal use BDD vs BDT • Behavior Driven Development (BDD) – Development domain – White box – Micro view – Input = specification (Behavior) – Output = Implementation • Behavior Driven Testing (BDT) – Test domain – Black box (interface) – Macro view – Input = Specification (Behavior) – Output = Test
  • 26. Confidential GTC-NL for internal use Requirement Based Testing in one slide Feature file (Scenario’s: Given When Then) Test class (for Nunit) Generated by SpecFow tool (.cs) Stepper class binding with implementation (.cs) SUT (FlashLite) Nunit dll Bello/Nunit Test report Visual Studio 2010 + SpecFlow Requirements doc SW/FW developer implementation code Development environment User SW/FW Implementation feedback 4 3 2 1 5 Spec.doc to Feature file convertor (2) = refactor= clean up and improveTester To be developed
  • 27. Confidential GTC-NL for internal use Learn more about SpecFlow and BDD http://blog.dannorth.net/introducing-bdd/ http://www.specflow.org/ https://github.com/techtalk/SpecFlow http://github.com/techtalk/SpecFlow-Examples http://github.com/aslakhellesoy/cucumber/wiki http://www.marcusoft.net/search/label/SpecFlow https://github.com/marcushammarberg/ https://www.marcusoft.net Free downloadable book
  • 29. 1, 2, 3 Given When Then [TestMethod] public void Total_Should_Be_1_When_1_Product_Added() { var cart = new ShoppingCart("TEST"); cart.AddItem(new Product("SKU")); Assert.AreEqual(1, cart.TotalItems); }