SlideShare a Scribd company logo
1 of 60
AUTOMATED
ACCEPTANCE TESTING IN
.NET
Wyn Van Devanter
wyn.vandevanter@excella.com
@wynv
Agenda
• Part I: AAT Overview
• Part II: Pros & Cons of AAT
• Part III: AAT Tools and Syntax in .NET
• Part IV: Overcoming the Cons of AAT
• Part V: Demo
Part I
AAT Overview
Legacy Nightmare
<div class="pdl13 pdr15">
<div class="fll w744">
<div class="wp100 bdr02 bgc03">
<div class="pd08 mostDownload01_l vat">
<div class="bgc02 vat">
<div class="mostDownload_m bgc02 vat">
<div class="wp100">
<div class="fll bgc05 pdr03 h20">
Automated Acceptance Tests (AATs)
Given – When – Then
Given I am hungry
When I eat 2 pickles
Then I am less hungry
End-to-end UI, Integration tests
UI
Service
Unit
Black box
White box
End-to-end
Business facing
Localized
Technology
facing
Manual Checking
End-to-end
UI
Integration
Unit
SOURCE: http://blogs.agilefaqs.com/2011/02/01/inverting-the-testing-pyramid
Manual
Checking
Inverting the Testing Pyramid
UI
Acceptance, Integration
Unit
Acceptance Test Strategy
Happy paths, major unhappy paths, legacy
Who writes acceptance tests?
What can you write them in?
Vim
Why Have AATs?
Communication
• Helps specify behavior of the system in plain text
• Provides a medium for non-tech and devs to agree on
Are we
talking
about
the right
system?
Seams, unit test mistakes
Automation
“There’s no place for
human beings to be
doing regression testing
manually.”
-Jez Humble
Save resources
Acceptance
Test Driven Development (ATDD)
Why NOT have ATTs?
• Business users won‟t write specifications
• Brittle and slow
• High false negatives, non-determinism
“Certainly it is not necessary to run every
example to be sure that the code works.
Probably it is necessary to run some.”
– Ron Jeffries
Questions?
Part II
Tools and Syntax
Various Frameworks
Browser driver
Browser automation
Test runner/harness
BDD Framework
.NET
Selenium, Phanto
m.js
Selenium,
Waitn
NUnit, xUnit, MST
est
SpecFlow,
Fitness (.NET
runner), Cuke4Nu
ke, MSpec
JavaScript
Selemium, Phant
om.js
Phantom.js/Casp
er.js
Mocha, Jasmine
Chai, Jasmine
Java/Ruby
Selenium, Phantom
.js
Selenium,
Waitr
JUnit, test-unit
JBehave, Fitness,
Cucumber/RSpec/
Capybara
Various Frameworks
Browser driver
Browser automation
Test runner/harness
BDD Framework
.NET
Selenium, Phant
om.js
Selenium,
Waitn
NUnit, xUnit, MS
Test
SpecFlow,
Fitness (.NET
runner), Cuke4Nu
ke,
MSpec
JavaScript
Selemium, Phant
om.js
Phantom.js/Casp
er.js
Mocha, Jasmine
Chai, Jasmine
Java/Ruby
Selenium,
Phantom.js
Selenium,
Waitr
JUnit, test-unit
JBehave, Fitness,
Cucumber/RSpec/
Capybara
App
UI/Integration Tests
Page Objects
Acceptance Tests
Architecture with SpecFlow
Getting set up
Getting set up
Getting set up
SpecFlow Workflow
Start with a story
User story
As an internet user,
I want to search for “ALT.NET”
And get valid results
• Acceptance criteria 1: I get at least 100k results
• Acceptance criteria 2: Results ordered by relevance
…
Scenarios
Feature
Gherkin in a SpecFlow feature
Feature: Google Search
As an internet user
I want to search for “ALT.NET”
So that I can be knowledgeable about the organzation
Background: I am logged into my Google account
Scenario: Search for „ALT.NET‟
Given I am on the Google Home Page
When I search for ”ALT.NET"
Then I should see at least 100,000 results
And the results should be ordered by relevance
Step
Generate Step Definitions
[When(@"I search for ""(.+)""")]
public void WhenISearchForSomething(string searchTerm)
{
GoogleSearchResultsPage = GoogleHomePage.Search(searchTerm);
}
Step Definition
Running tests
Demo
Test Data
• Populate a database with expected data for tests
• Separately, or on startup of all/single test(s) & remove in
tear down
Tracking AATs
Living documentation
• Pickles - Html, Word, DITA and json
Questions?
Part IV
Overcoming the Cons of
AATs
Minimize # of end-to-end tests
• AATs for journeys, not stories
• Is your new story entirely new?
• Balance high # of unit tests + selected end-to-end &
acceptance
Page Objects
public class GoogleHomepage: PageBase, IGoogleHomepage {
// Flow for this page
}
GoogleHomepage
+search(query)
+clickSearch()
+clickGettingLucky
SpecFlow Workflow with Page Object
public class GoogleHomepage: PageBase, IGoogleHomepage {
// Flow for this page
}
Domain
Service
UI
GoogleHomepage
+search(query)
+clickSearch()
+clickGettingLucky Data Access
GoogleHomepageService
+search(query)
+clickSearch()
+clickGettingLucky
IGoogleHomepage
+search(query)
+clickSearch()
+clickGettingLucky
Concise Specs
• Declarative
• Reuse steps
• Concise, many methods, fat fixtures
Bad:
• Click on Log In button
• Click username box and type „myUsername‟ and click „password‟ box and type
„myPassword‟
• Click on link for Transfer Payment
• Click box for amount and type 400
• Click „Transfer‟ button
• Assert success message
Good:
• Login as „MyAccountName‟
• Navigate to Transfer Payment page
• Transfer 400 dollars
• Assert success message
Use a headless browser
Don‟t go through the UI
• Controller down, service down
• Use mocks, stubs
When Acceptances Tests catches a bug
• See why bug got through unit/integration tests
• Add unit, integration tests
• Prune AAT?
Unit
Tips
Developer tips
• Don't run in same assembly as other tests, so these can
be run separately since they're very slow (i.e. nightly)
• Navigation
• Haywire! Sometimes when moving step definitions
around, the gherkin gets confused and can‟t find the
target. Restart VS.
Developer tips
[Given(@"I am not logged in")]
[When(@"I am not logged in")]
public void IAmNotLoggedIn()
{
…
}
Gherkin
• Describe what, not how (Don‟t: „Click the Log In button‟. Do:
„Navigate to the log in screen‟)
• Specs shouldn‟t have much setup code
Given I am on the homepage
And I click login
And I enter username of „username‟ and password of „password‟
When clicking „Log In‟
Then take me to my landing page
Given I am on the homepage
When logging in with „username‟ and „password‟
Then take me to my landing page
Scenario Outline
Parameterize!
Scenario: eat 5 out of 12
Given there are 12 cucumbers
When I eat 5 cucumbers
Then I should have 7 cucumbers
Scenario: eat 5 out of 20
Given there are 20 cucumbers
When I eat 5 cucumbers
Then I should have 15 cucumbers
Scenario Outline
Parameterize!
Scenario Outline: eating
Given there are <start> cucumbers
When I eat <eat> cucumbers
Then I should have <left> cucumbers
Examples:
| start | eat | left |
| 12 | 5 | 7 |
| 20 | 5 | 15 |
Parameters
Given I entered the following data into the new account form:
| Field | Value |
| Name | John Galt |
| Birthdate | 2/2/1902 |
| HeightInInches | 72 |
| BankAccountBalance | 1234.56 |
or in a horizontal table like this:
| Name | Birthdate | HeightInInches | BankAccountBalance |
| John Galt | 2/2/1902 | 72 | 1234.56 |
| John Doe | 1/1/1980 | 68 | 1111.99 |
UI tests
• Sometimes tests will fail if the page doesn‟t have enough
time to load. Use implicit waits, and explicit when really
needed
• Capture screen shots when tests fail
• Selenium IDE
Anti-patterns
• Developers writing acceptance tests by themselves, for
themselves
• Tying AATs to an implementation - unit tests are
implementation specific, AATs are NOT
• Too much repetition in the gherkin
• Too many UI tests
Demo
Conclusion
Resources:
Tools used here:
• SpecFlow – specflow.org
• PhantomJS – phantomjs.org
• Selenium WebDriver – seleniumhq.org
Books:
• Specification By Example, Gojko Adzic
• Continuous Delivery, Jez Humble, David Farley
• Growing Object-Oriented Software, Guided By Tests, Steve Freeman, Nat Pryce
Articles:
• Automated Acceptance Tests, http://www.thoughtworks.com/insights/articles/automated-acceptance-tests
• BDD with SpecFlow and ASP.NET MVC, http://blog.stevensanderson.com/2010/03/03/behavior-driven-
development-bdd-with-specflow-and-aspnet-mvc/
• Using Gherkin Language in SpecFlow,
https://github.com/techtalk/SpecFlow/wiki/Using-Gherkin-Language-in-SpecFlow
• BDD with SpecFlow, MSDN, http://msdn.microsoft.com/en-us/magazine/gg490346.aspx
• Using SpecFlow with the Page Object, http://blogs.lessthandot.com/index.php/EnterpriseDev/application-lifecycle-
management/using-specflow-to
• Problems with Acceptance Tests, http://xprogramming.com/xpmag/problems-with-acceptance-testing
• Top 10 reasons why teams fail with Acceptance Testing, http://gojko.net/2009/09/24/top-10-reasons-why-teams-
fail-with-acceptance-testing/
• Maintaining Automated Acceptance Tests (ThoughtWorks), http://www.youtube.com/watch?v=uf0EVbH5hdA
• Creating Maintainable Automated Acceptance Test Suites, Jez Humble,
• http://www.youtube.com/watch?v=v-L_2y6g5DI
Happy Three Amigos
Slides: http://www.slideshare.net/wynvandevanter/automated-acceptance-
tests-in-net
Code:
https://github.com/Wyntuition/AATsInSpecFlowDemos
wyn.vandevanter@excella.com
@wynv

More Related Content

What's hot

Behavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile TestingBehavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile Testingdversaci
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium SuccessfullyDave Haeffner
 
Improving The Quality of Existing Software
Improving The Quality of Existing SoftwareImproving The Quality of Existing Software
Improving The Quality of Existing SoftwareSteven Smith
 
Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016Steven Smith
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing SoftwareSteven Smith
 
Continuous Testing Meets the Classroom at Code.org
Continuous Testing Meets the Classroom at Code.orgContinuous Testing Meets the Classroom at Code.org
Continuous Testing Meets the Classroom at Code.orgSauce Labs
 
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)Alvaro Sanchez-Mariscal
 
Spec flow – functional testing made easy
Spec flow – functional testing made easySpec flow – functional testing made easy
Spec flow – functional testing made easyPaul Stack
 
Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Brian Sam-Bodden
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium SuccessfullyDave Haeffner
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Lars Thorup
 
Behavior Driven Development with SpecFlow
Behavior Driven Development with SpecFlowBehavior Driven Development with SpecFlow
Behavior Driven Development with SpecFlowRachid Kherrazi
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing SoftwareSteven Smith
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by ExampleNalin Goonawardana
 
5 Considerations When Adopting Automated Testing
5 Considerations When Adopting Automated Testing5 Considerations When Adopting Automated Testing
5 Considerations When Adopting Automated TestingBhupesh Dahal
 

What's hot (20)

Behavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile TestingBehavior Driven Development (BDD) and Agile Testing
Behavior Driven Development (BDD) and Agile Testing
 
SpecFlow for Agile Teams
SpecFlow for Agile TeamsSpecFlow for Agile Teams
SpecFlow for Agile Teams
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Improving The Quality of Existing Software
Improving The Quality of Existing SoftwareImproving The Quality of Existing Software
Improving The Quality of Existing Software
 
Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016Improving the Quality of Existing Software - DevIntersection April 2016
Improving the Quality of Existing Software - DevIntersection April 2016
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing Software
 
BDD for APIs
BDD for APIsBDD for APIs
BDD for APIs
 
Continuous Testing Meets the Classroom at Code.org
Continuous Testing Meets the Classroom at Code.orgContinuous Testing Meets the Classroom at Code.org
Continuous Testing Meets the Classroom at Code.org
 
Selenium Frameworks
Selenium FrameworksSelenium Frameworks
Selenium Frameworks
 
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
 
Spec flow – functional testing made easy
Spec flow – functional testing made easySpec flow – functional testing made easy
Spec flow – functional testing made easy
 
Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
 
React a11y-csun
React a11y-csunReact a11y-csun
React a11y-csun
 
Behavior Driven Development with SpecFlow
Behavior Driven Development with SpecFlowBehavior Driven Development with SpecFlow
Behavior Driven Development with SpecFlow
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing Software
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
5 Considerations When Adopting Automated Testing
5 Considerations When Adopting Automated Testing5 Considerations When Adopting Automated Testing
5 Considerations When Adopting Automated Testing
 
Test Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and CucumberTest Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and Cucumber
 

Similar to Automated Acceptance Tests in .NET

Automated Acceptance Test Practices and Pitfalls
Automated Acceptance Test Practices and PitfallsAutomated Acceptance Test Practices and Pitfalls
Automated Acceptance Test Practices and PitfallsWyn B. Van Devanter
 
Testable Requirements
Testable Requirements Testable Requirements
Testable Requirements Bharti Rupani
 
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsBrowser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsLuís Bastião Silva
 
Being Epic: Best Practices for Android Development
Being Epic: Best Practices for Android DevelopmentBeing Epic: Best Practices for Android Development
Being Epic: Best Practices for Android DevelopmentReto Meier
 
Test automation lesson
Test automation lessonTest automation lesson
Test automation lessonSadaaki Emura
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETBen Hall
 
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and BeyondWebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyondmguillem
 
Abraham aranguren. legal and efficient web app testing without permission
Abraham aranguren. legal and efficient web app testing without permissionAbraham aranguren. legal and efficient web app testing without permission
Abraham aranguren. legal and efficient web app testing without permissionYury Chemerkin
 
Bdd with Cucumber and Mocha
Bdd with Cucumber and MochaBdd with Cucumber and Mocha
Bdd with Cucumber and MochaAtish Narlawar
 
Пирамида Тестирования через призму ROI калькулятора и прочая геометрия
Пирамида Тестирования через призму ROI калькулятора и прочая геометрияПирамида Тестирования через призму ROI калькулятора и прочая геометрия
Пирамида Тестирования через призму ROI калькулятора и прочая геометрияSQALab
 
Test Pyramid vs Roi
Test Pyramid vs Roi Test Pyramid vs Roi
Test Pyramid vs Roi COMAQA.BY
 
Tech Talk on Cloud Computing
Tech Talk on Cloud ComputingTech Talk on Cloud Computing
Tech Talk on Cloud ComputingITviec
 
Load testing using_neoload by kc
Load testing using_neoload by kcLoad testing using_neoload by kc
Load testing using_neoload by kckrishna chaitanya
 
Are you getting traction - Tales from the tech transfer trenches
Are you getting traction - Tales from the tech transfer trenchesAre you getting traction - Tales from the tech transfer trenches
Are you getting traction - Tales from the tech transfer trenchesSatish Chandra
 
CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!Ortus Solutions, Corp
 

Similar to Automated Acceptance Tests in .NET (20)

Automated Acceptance Test Practices and Pitfalls
Automated Acceptance Test Practices and PitfallsAutomated Acceptance Test Practices and Pitfalls
Automated Acceptance Test Practices and Pitfalls
 
Testable Requirements
Testable Requirements Testable Requirements
Testable Requirements
 
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsBrowser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.js
 
Testable requirements
Testable requirementsTestable requirements
Testable requirements
 
QAorHighway2016
QAorHighway2016QAorHighway2016
QAorHighway2016
 
Being Epic: Best Practices for Android Development
Being Epic: Best Practices for Android DevelopmentBeing Epic: Best Practices for Android Development
Being Epic: Best Practices for Android Development
 
Test automation lesson
Test automation lessonTest automation lesson
Test automation lesson
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
 
Codeception
CodeceptionCodeception
Codeception
 
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and BeyondWebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
 
Abraham aranguren. legal and efficient web app testing without permission
Abraham aranguren. legal and efficient web app testing without permissionAbraham aranguren. legal and efficient web app testing without permission
Abraham aranguren. legal and efficient web app testing without permission
 
Bdd with Cucumber and Mocha
Bdd with Cucumber and MochaBdd with Cucumber and Mocha
Bdd with Cucumber and Mocha
 
Neoload
Neoload Neoload
Neoload
 
Пирамида Тестирования через призму ROI калькулятора и прочая геометрия
Пирамида Тестирования через призму ROI калькулятора и прочая геометрияПирамида Тестирования через призму ROI калькулятора и прочая геометрия
Пирамида Тестирования через призму ROI калькулятора и прочая геометрия
 
Test Pyramid vs Roi
Test Pyramid vs Roi Test Pyramid vs Roi
Test Pyramid vs Roi
 
Tech Talk on Cloud Computing
Tech Talk on Cloud ComputingTech Talk on Cloud Computing
Tech Talk on Cloud Computing
 
Load testing using_neoload by kc
Load testing using_neoload by kcLoad testing using_neoload by kc
Load testing using_neoload by kc
 
Top Testing Tips
Top Testing TipsTop Testing Tips
Top Testing Tips
 
Are you getting traction - Tales from the tech transfer trenches
Are you getting traction - Tales from the tech transfer trenchesAre you getting traction - Tales from the tech transfer trenches
Are you getting traction - Tales from the tech transfer trenches
 
CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!
 

More from Wyn B. Van Devanter

Container orchestration overview
Container orchestration overviewContainer orchestration overview
Container orchestration overviewWyn B. Van Devanter
 
AWS Elastic Container Service (ECS) with a CI Pipeline Overview
AWS Elastic Container Service (ECS) with a CI Pipeline OverviewAWS Elastic Container Service (ECS) with a CI Pipeline Overview
AWS Elastic Container Service (ECS) with a CI Pipeline OverviewWyn B. Van Devanter
 
Performance tuning an Object-Relational Mapper (ORM)
Performance tuning an Object-Relational Mapper (ORM)Performance tuning an Object-Relational Mapper (ORM)
Performance tuning an Object-Relational Mapper (ORM)Wyn B. Van Devanter
 

More from Wyn B. Van Devanter (7)

Container orchestration overview
Container orchestration overviewContainer orchestration overview
Container orchestration overview
 
Developer workflow with docker
Developer workflow with dockerDeveloper workflow with docker
Developer workflow with docker
 
AWS Elastic Container Service (ECS) with a CI Pipeline Overview
AWS Elastic Container Service (ECS) with a CI Pipeline OverviewAWS Elastic Container Service (ECS) with a CI Pipeline Overview
AWS Elastic Container Service (ECS) with a CI Pipeline Overview
 
Benefits from AATs
Benefits from AATsBenefits from AATs
Benefits from AATs
 
Developer workflow with docker
Developer workflow with dockerDeveloper workflow with docker
Developer workflow with docker
 
.Net Core 1.0 vs .NET Framework
.Net Core 1.0 vs .NET Framework.Net Core 1.0 vs .NET Framework
.Net Core 1.0 vs .NET Framework
 
Performance tuning an Object-Relational Mapper (ORM)
Performance tuning an Object-Relational Mapper (ORM)Performance tuning an Object-Relational Mapper (ORM)
Performance tuning an Object-Relational Mapper (ORM)
 

Recently uploaded

Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...
Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...
Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...JeylaisaManabat1
 
integrity in personal relationship (1).pdf
integrity in personal relationship (1).pdfintegrity in personal relationship (1).pdf
integrity in personal relationship (1).pdfAmitRout25
 
Benefits of Co working & Shared office space in India
Benefits of Co working & Shared office space in IndiaBenefits of Co working & Shared office space in India
Benefits of Co working & Shared office space in IndiaBrantfordIndia
 
ingrediendts needed in preparing dessert and sweet sauces
ingrediendts needed in preparing dessert and sweet saucesingrediendts needed in preparing dessert and sweet sauces
ingrediendts needed in preparing dessert and sweet saucesJessicaEscao
 
The 5 sec rule - Mel Robins (Hindi Summary)
The 5 sec rule - Mel Robins (Hindi Summary)The 5 sec rule - Mel Robins (Hindi Summary)
The 5 sec rule - Mel Robins (Hindi Summary)Shakti Savarn
 
Call Girls Dubai O525547819 Favor Dubai Call Girls Agency
Call Girls Dubai O525547819 Favor Dubai Call Girls AgencyCall Girls Dubai O525547819 Favor Dubai Call Girls Agency
Call Girls Dubai O525547819 Favor Dubai Call Girls Agencykojalkojal131
 
Virtue ethics & Effective Altruism: What can EA learn from virtue ethics?
Virtue ethics & Effective Altruism: What can EA learn from virtue ethics?Virtue ethics & Effective Altruism: What can EA learn from virtue ethics?
Virtue ethics & Effective Altruism: What can EA learn from virtue ethics?Mikko Kangassalo
 
Spiritual Life Quote from Shiva Negi
Spiritual Life Quote from Shiva Negi Spiritual Life Quote from Shiva Negi
Spiritual Life Quote from Shiva Negi OneDay18
 
English basic for beginners Future tenses .pdf
English basic for beginners Future tenses .pdfEnglish basic for beginners Future tenses .pdf
English basic for beginners Future tenses .pdfbromerom1
 

Recently uploaded (9)

Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...
Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...
Module-2-Lesson-2-COMMUNICATION-AIDS-AND-STRATEGIES-USING-TOOLS-OF-TECHNOLOGY...
 
integrity in personal relationship (1).pdf
integrity in personal relationship (1).pdfintegrity in personal relationship (1).pdf
integrity in personal relationship (1).pdf
 
Benefits of Co working & Shared office space in India
Benefits of Co working & Shared office space in IndiaBenefits of Co working & Shared office space in India
Benefits of Co working & Shared office space in India
 
ingrediendts needed in preparing dessert and sweet sauces
ingrediendts needed in preparing dessert and sweet saucesingrediendts needed in preparing dessert and sweet sauces
ingrediendts needed in preparing dessert and sweet sauces
 
The 5 sec rule - Mel Robins (Hindi Summary)
The 5 sec rule - Mel Robins (Hindi Summary)The 5 sec rule - Mel Robins (Hindi Summary)
The 5 sec rule - Mel Robins (Hindi Summary)
 
Call Girls Dubai O525547819 Favor Dubai Call Girls Agency
Call Girls Dubai O525547819 Favor Dubai Call Girls AgencyCall Girls Dubai O525547819 Favor Dubai Call Girls Agency
Call Girls Dubai O525547819 Favor Dubai Call Girls Agency
 
Virtue ethics & Effective Altruism: What can EA learn from virtue ethics?
Virtue ethics & Effective Altruism: What can EA learn from virtue ethics?Virtue ethics & Effective Altruism: What can EA learn from virtue ethics?
Virtue ethics & Effective Altruism: What can EA learn from virtue ethics?
 
Spiritual Life Quote from Shiva Negi
Spiritual Life Quote from Shiva Negi Spiritual Life Quote from Shiva Negi
Spiritual Life Quote from Shiva Negi
 
English basic for beginners Future tenses .pdf
English basic for beginners Future tenses .pdfEnglish basic for beginners Future tenses .pdf
English basic for beginners Future tenses .pdf
 

Automated Acceptance Tests in .NET

  • 1. AUTOMATED ACCEPTANCE TESTING IN .NET Wyn Van Devanter wyn.vandevanter@excella.com @wynv
  • 2. Agenda • Part I: AAT Overview • Part II: Pros & Cons of AAT • Part III: AAT Tools and Syntax in .NET • Part IV: Overcoming the Cons of AAT • Part V: Demo
  • 4. Legacy Nightmare <div class="pdl13 pdr15"> <div class="fll w744"> <div class="wp100 bdr02 bgc03"> <div class="pd08 mostDownload01_l vat"> <div class="bgc02 vat"> <div class="mostDownload_m bgc02 vat"> <div class="wp100"> <div class="fll bgc05 pdr03 h20">
  • 6. Given – When – Then Given I am hungry When I eat 2 pickles Then I am less hungry
  • 8. UI Service Unit Black box White box End-to-end Business facing Localized Technology facing
  • 10. Manual Checking Inverting the Testing Pyramid UI Acceptance, Integration Unit
  • 11. Acceptance Test Strategy Happy paths, major unhappy paths, legacy
  • 13. What can you write them in? Vim
  • 15. Communication • Helps specify behavior of the system in plain text • Provides a medium for non-tech and devs to agree on Are we talking about the right system?
  • 16. Seams, unit test mistakes
  • 17. Automation “There’s no place for human beings to be doing regression testing manually.” -Jez Humble
  • 20. Why NOT have ATTs? • Business users won‟t write specifications • Brittle and slow • High false negatives, non-determinism “Certainly it is not necessary to run every example to be sure that the code works. Probably it is necessary to run some.” – Ron Jeffries
  • 23. Various Frameworks Browser driver Browser automation Test runner/harness BDD Framework .NET Selenium, Phanto m.js Selenium, Waitn NUnit, xUnit, MST est SpecFlow, Fitness (.NET runner), Cuke4Nu ke, MSpec JavaScript Selemium, Phant om.js Phantom.js/Casp er.js Mocha, Jasmine Chai, Jasmine Java/Ruby Selenium, Phantom .js Selenium, Waitr JUnit, test-unit JBehave, Fitness, Cucumber/RSpec/ Capybara
  • 24. Various Frameworks Browser driver Browser automation Test runner/harness BDD Framework .NET Selenium, Phant om.js Selenium, Waitn NUnit, xUnit, MS Test SpecFlow, Fitness (.NET runner), Cuke4Nu ke, MSpec JavaScript Selemium, Phant om.js Phantom.js/Casp er.js Mocha, Jasmine Chai, Jasmine Java/Ruby Selenium, Phantom.js Selenium, Waitr JUnit, test-unit JBehave, Fitness, Cucumber/RSpec/ Capybara
  • 25. App UI/Integration Tests Page Objects Acceptance Tests Architecture with SpecFlow
  • 30. Start with a story User story As an internet user, I want to search for “ALT.NET” And get valid results • Acceptance criteria 1: I get at least 100k results • Acceptance criteria 2: Results ordered by relevance … Scenarios Feature
  • 31. Gherkin in a SpecFlow feature Feature: Google Search As an internet user I want to search for “ALT.NET” So that I can be knowledgeable about the organzation Background: I am logged into my Google account Scenario: Search for „ALT.NET‟ Given I am on the Google Home Page When I search for ”ALT.NET" Then I should see at least 100,000 results And the results should be ordered by relevance Step
  • 32. Generate Step Definitions [When(@"I search for ""(.+)""")] public void WhenISearchForSomething(string searchTerm) { GoogleSearchResultsPage = GoogleHomePage.Search(searchTerm); } Step Definition
  • 34. Demo
  • 35. Test Data • Populate a database with expected data for tests • Separately, or on startup of all/single test(s) & remove in tear down
  • 37. Living documentation • Pickles - Html, Word, DITA and json
  • 39. Part IV Overcoming the Cons of AATs
  • 40. Minimize # of end-to-end tests • AATs for journeys, not stories • Is your new story entirely new? • Balance high # of unit tests + selected end-to-end & acceptance
  • 41. Page Objects public class GoogleHomepage: PageBase, IGoogleHomepage { // Flow for this page } GoogleHomepage +search(query) +clickSearch() +clickGettingLucky
  • 42. SpecFlow Workflow with Page Object
  • 43. public class GoogleHomepage: PageBase, IGoogleHomepage { // Flow for this page } Domain Service UI GoogleHomepage +search(query) +clickSearch() +clickGettingLucky Data Access GoogleHomepageService +search(query) +clickSearch() +clickGettingLucky IGoogleHomepage +search(query) +clickSearch() +clickGettingLucky
  • 44. Concise Specs • Declarative • Reuse steps • Concise, many methods, fat fixtures Bad: • Click on Log In button • Click username box and type „myUsername‟ and click „password‟ box and type „myPassword‟ • Click on link for Transfer Payment • Click box for amount and type 400 • Click „Transfer‟ button • Assert success message Good: • Login as „MyAccountName‟ • Navigate to Transfer Payment page • Transfer 400 dollars • Assert success message
  • 45. Use a headless browser
  • 46. Don‟t go through the UI • Controller down, service down • Use mocks, stubs
  • 47. When Acceptances Tests catches a bug • See why bug got through unit/integration tests • Add unit, integration tests • Prune AAT? Unit
  • 48. Tips
  • 49. Developer tips • Don't run in same assembly as other tests, so these can be run separately since they're very slow (i.e. nightly) • Navigation • Haywire! Sometimes when moving step definitions around, the gherkin gets confused and can‟t find the target. Restart VS.
  • 50. Developer tips [Given(@"I am not logged in")] [When(@"I am not logged in")] public void IAmNotLoggedIn() { … }
  • 51. Gherkin • Describe what, not how (Don‟t: „Click the Log In button‟. Do: „Navigate to the log in screen‟) • Specs shouldn‟t have much setup code Given I am on the homepage And I click login And I enter username of „username‟ and password of „password‟ When clicking „Log In‟ Then take me to my landing page Given I am on the homepage When logging in with „username‟ and „password‟ Then take me to my landing page
  • 52. Scenario Outline Parameterize! Scenario: eat 5 out of 12 Given there are 12 cucumbers When I eat 5 cucumbers Then I should have 7 cucumbers Scenario: eat 5 out of 20 Given there are 20 cucumbers When I eat 5 cucumbers Then I should have 15 cucumbers
  • 53. Scenario Outline Parameterize! Scenario Outline: eating Given there are <start> cucumbers When I eat <eat> cucumbers Then I should have <left> cucumbers Examples: | start | eat | left | | 12 | 5 | 7 | | 20 | 5 | 15 |
  • 54. Parameters Given I entered the following data into the new account form: | Field | Value | | Name | John Galt | | Birthdate | 2/2/1902 | | HeightInInches | 72 | | BankAccountBalance | 1234.56 | or in a horizontal table like this: | Name | Birthdate | HeightInInches | BankAccountBalance | | John Galt | 2/2/1902 | 72 | 1234.56 | | John Doe | 1/1/1980 | 68 | 1111.99 |
  • 55. UI tests • Sometimes tests will fail if the page doesn‟t have enough time to load. Use implicit waits, and explicit when really needed • Capture screen shots when tests fail • Selenium IDE
  • 56. Anti-patterns • Developers writing acceptance tests by themselves, for themselves • Tying AATs to an implementation - unit tests are implementation specific, AATs are NOT • Too much repetition in the gherkin • Too many UI tests
  • 57. Demo
  • 59. Resources: Tools used here: • SpecFlow – specflow.org • PhantomJS – phantomjs.org • Selenium WebDriver – seleniumhq.org Books: • Specification By Example, Gojko Adzic • Continuous Delivery, Jez Humble, David Farley • Growing Object-Oriented Software, Guided By Tests, Steve Freeman, Nat Pryce Articles: • Automated Acceptance Tests, http://www.thoughtworks.com/insights/articles/automated-acceptance-tests • BDD with SpecFlow and ASP.NET MVC, http://blog.stevensanderson.com/2010/03/03/behavior-driven- development-bdd-with-specflow-and-aspnet-mvc/ • Using Gherkin Language in SpecFlow, https://github.com/techtalk/SpecFlow/wiki/Using-Gherkin-Language-in-SpecFlow • BDD with SpecFlow, MSDN, http://msdn.microsoft.com/en-us/magazine/gg490346.aspx • Using SpecFlow with the Page Object, http://blogs.lessthandot.com/index.php/EnterpriseDev/application-lifecycle- management/using-specflow-to • Problems with Acceptance Tests, http://xprogramming.com/xpmag/problems-with-acceptance-testing • Top 10 reasons why teams fail with Acceptance Testing, http://gojko.net/2009/09/24/top-10-reasons-why-teams- fail-with-acceptance-testing/ • Maintaining Automated Acceptance Tests (ThoughtWorks), http://www.youtube.com/watch?v=uf0EVbH5hdA • Creating Maintainable Automated Acceptance Test Suites, Jez Humble, • http://www.youtube.com/watch?v=v-L_2y6g5DI
  • 60. Happy Three Amigos Slides: http://www.slideshare.net/wynvandevanter/automated-acceptance- tests-in-net Code: https://github.com/Wyntuition/AATsInSpecFlowDemos wyn.vandevanter@excella.com @wynv

Editor's Notes

  1. Ask Q’s
  2. Bad legacy code in mission critical system, not unit testable…Useful in general in a test suite for many reasons…
  3. AcceptanceTestsFits their requirements. The story is complete. Automated
  4. Readable by whole spectrum
  5. What kind of tests do you run with your specs?UI – smoke, sanity, UI goo Functionality – Integration testsRun close to production; like a user would.
  6. Mostly unit testsHARD to maintain, slow SO….
  7. Unit test everything thru JavaScriptMost RELEVANT test cases for AATs (can’t hit all alt paths)Shouldn’t manually regression test
  8. Whoever writes user storiesDev/Tester/BA BEFORE iteration starts
  9. -Communication with business stakeholders, BAs, QA
  10. -Unit tests don’t account for everything, seams-Gaps in coverage, unit tests not hitting right test cases,
  11. -Full regression doesn’t always happen-Manual testing lapseMistakes in testing, non-testing, non-regressingAllow testers to do more exploratory and higher level things, less boring
  12. Bugs will be caught earlier
  13. Not doing, btw
  14. Some have even said it’s not worth the cost
  15. Create a spec in gherkinGerkin is a line-oriented language (line  step)In SpecFlow, Generate step definitionsIn Selenium &amp; NUnit, write UI/integration tests to power the AATs
  16. All know definition of User Story? Should be turned into specs before iteration starts (bus &amp; )
  17. Given – set up the context of your testWhen – action performed by userThen - asserts
  18. Represents flow of pages in app
  19. ----- Meeting Notes (7/2/13 12:08) ------spelling