functional testing the_good_the_bad_and_the_ugly
TRANSCRIPT
Technical Agile Practices
Test Driven Development
Continuous Integration/Delivery
Automated
Acceptance Criteria
Refactoring
Pair
Progra
mming
“Without these technical prac1ces, your agile adop1on is hollow”-‐ Ma6 Wynne
Technical Agile Practices
Test Driven Development
Continuous Integration/Delivery
Automated Acceptance Criteria
Refactoring
Pair
Progra
mming
“Without these technical prac1ces, your agile adop1on is hollow”-‐ Ma6 Wynne
Business Rules
Business Flow
Page/Component interac<ons
Page/Component details
Good automated acceptance tests have layers
WebDriver / Selenium 2
Mature browser automa<on
Wide adop<on
Cross-‐browser support
Cross-‐browser support
WatirWeb Application Testing in Ruby
browser.goto 'http://bit.ly/watir-example'browser.text_field(:name => 'entry.0.single').set 'Watir'browser.checkbox(:value => 'Ruby').set
Ruby DSL for web tes<ng
WebDriver-‐based
Fluent and readable
No na<ve support for Page Objects?
GebGroovy Browser Automation
Browser.drive { go "http://myapp.com/login" assert $("h1").text() == "Please Login" $("form.login").with { username = "admin" password = "password" login().click() } assert $("h1").text() == "Admin Section"}
Groovy DSL for web tes<ng
WebDriver-‐based
Fluent and readable
Supports Page Objects
29
Narrative:In order to increase sales of advertised articlesAs a sellerI want buyers to be able to easily find ads for articles they want to buy
Scenario: Searching by keyword and location
Given Sally wants to buy a puppy for her son When she looks for 'puppy' in the 'Pets and Animals' category Then she should obtain a list of ads for puppies for sale.
search_by_keyword_and_location.story
Business-‐friendly specifica<ons
An example in JBehave
30
Scenario: Searching by keyword and location
Given Sally wants to buy a puppy for her son When she looks for 'puppy' in the 'Pets and Animals' category Then she should obtain a list of ads for puppies for sale.
search_by_keyword_and_location.story
Scenario: Searching by keyword and location
Given Sally wants to buy a <present> for her son When she looks for '<present>' in the '<category>' category Then she should obtain a list of ads for <expected> for sale.
Examples:|present |category |expected||puppy |Pets & Animals | puppies||kitten |Pets & Animals | kittens||seiko |Jewellery & Watches| watch |
Tabular examples
31
Scenario: Searching by keyword and location
Given Sally wants to buy a puppy for her son When she looks for 'puppy' in the 'Pets and Animals' category Then she should obtain a list of puppy ads
search_by_keyword_and_location.story
public class SearchAdsSteps { @Steps BuyerSteps buyer;
@Given("Sally wants to buy a $present for her son") public void buyingAPresent(String present) { buyer.opens_home_page(); }
@When("she looks for $keyword in the $category category") public void adSearchByCategoryAndKeyword(String category, String keyword) { buyer.chooses_category_and_keywords(category, keyword); buyer.performs_search(); }
@Then("she should obtain a list of $keyword ads") public void shouldOnlySeeAdsContainingKeyword(String keyword) { buyer.should_only_see_results_with_titles_containing(keyword); }}
Step implementa<ons in your favorite language
34
2 Automate your acceptance criteria
1 Discover your acceptance criteria
4 Execute your acceptance tests
3 Implement your acceptance criteria
35
1 Discover your acceptance criteria
Feature: Browse CatalogIn order to find items that I would like to buyAs a customerI want to be able to browse through the catalog
Story: Browse by categoryIn order to find items more easilyAs a customerI want to be able to browse through the product categories
Acceptance CriteriaSee all the top-level categoriesBrowse through the category hierarchyShould display the correct products for each categoryEach category should have the correct sub-categories
Define acceptance criteria for each story
36
1 Discover your acceptance criteria
Acceptance CriteriaSee all the top-level categoriesBrowse through the category hierarchyShould display the correct products for each categoryEach category should have the correct sub-categories
Scenario: See all top-level categoriesGiven I want to browse the catalogWhen I am on the home pageThen I should see the following product categories: Clothing, Accessories, Shoes
Clarify the acceptance criteria with examples
37
2 Automate your acceptance criteria
Story: Browse by categoryIn order to find items more easilyAs a customerI want to be able to browse through the product categories
Acceptance CriteriaSee all the top-level categoriesBrowse through the category hierarchyShould display the correct products for each categoryEach category should have the correct sub-categories
Scenario: See all top-level categoriesGiven I want to browse the catalogWhen I am on the home pageThen I should see the following product categories: Clothing, Accessories, ShoesNarrative:
In order to find items more easilyAs a customerI want to be able to see what product categories exist
Scenario: See all top-level categoriesGiven I want to browse the catalogWhen I am on the home pageThen I should see the following product categories: Clothing, Accessories, Shoes
We now have executable specifica<ons
39
3 Implement your acceptance criteria
Narrative:In order to find items more easilyAs a customerI want to be able to see what product categories exist
Scenario: See all top-level categoriesGiven I want to browse the catalogWhen I am on the home pageThen I should see the following product categories: Clothing, Accessories, Shoes
hYp://wakaleo.com
hYp://thucydides.info
Want to learn more?