SlideShare une entreprise Scribd logo
1  sur  45
Télécharger pour lire hors ligne
Maintainable Acceptance Tests
                               Badrinath Janakiraman
                               Jez Humble
                               Agile 2012 Dallas

                               @badrij | badri@thoughtworks.com
                               @jezhumble | jez@thoughtworks.com




                          http://thoughtworks-studios.com/
Thursday, August 16, 12
what to expect
        • Creating high quality acceptance tests
        • How to structure a maintainable acceptance test
          suite
        • Patterns for effective teamwork
        • Managing test data




Thursday, August 16, 12
what to take away
        • Quality is everybody’s responsibility
        • High quality test suites are continuously curated
          - by testers and developers working together
        • Test code needs to receive the same care as
          production code
        • Exhaustive story-level testing is not a good
          basis for maintainable acceptance suites




Thursday, August 16, 12
different kinds of tests


                                                                  Business facing
                                                     AUTOMATED                       MANUAL

                                                                                Showcases
                          Support programming




                                                Functional acceptance
                                                                              Usability testing
                                                        tests




                                                                                                           Critique project
                                                                             Exploratory testing



                                                       Unit tests               Non-functional
                                                   Integration tests          acceptance tests
                                                     System tests         (performance, scaling, ...)
                                                     AUTOMATED               MANUAL / AUTOMATED

                                                                 Technology facing



                                                                                                        Diagram invented by Brian Marick

Thursday, August 16, 12
UI
                                    Mike Cohn:
                                    Succeeding with Agile
                          Service


                            Unit

Thursday, August 16, 12
End to End
                             Business Facing




                             Localized
                          Technology Facing

Thursday, August 16, 12
principle 0


        Writing good acceptance tests is
        hard.

        (good: when the tests are green,
        we know the software works)

Thursday, August 16, 12
mingle

                 2006             2012
                 20 tests         3000 tests
                 500 LOC          50k LOC
                 2 minutes        12 hours

              • actual running time: 55 minutes
              • 7-10 times a day
              • for 6 years, across 4 offices now

Thursday, August 16, 12
why do test suites decay?

   for the same reasons code does



   we don’t pay enough attention to expressing intent




   only testers care about maintaining tests

Thursday, August 16, 12
principles




Thursday, August 16, 12
principle 1


        Tests are first-class citizens of
        your project




Thursday, August 16, 12
preventing decay in test code

   treat test code as production c0de

   refactor relentlessly

   don’t repeat yourself

   don’t repeat yourself

   use record-playback tools to build your suite

Thursday, August 16, 12
preventing decay of intention


   given-when-then is insufficient


    separate intention from mechanics



   express the test as steps of a user's journey


Thursday, August 16, 12
a solution

    use natural language to express intentions



    use a general purpose programming language to
    express test mechanics


    use a tool that allows you to operate in either
    domain transparently

Thursday, August 16, 12
Thursday, August 16, 12
page object
                                                                         https://gist.github.com/3345556


    public class LoginPage {

        private final SeleniumSession browser;

        public LoginPage(Selenium browser){
          this.browser = browser;
        }

        public HomePage loginAs(String user, String password){
          browser.type('#login', login);
          browser.type('#password', password);
          browser.submit('#login-form');
          return new HomePage(this.browser);
        }

        public HomePage loginExpectingError(String user, String password){
          browser.type('#login', login);
          browser.type('#password', password);
          browser.submit('#login-form');
          return new LoginPage(this.browser);
        }
    }




Thursday, August 16, 12
Acceptance Criteria
                                            Customer    Tester




                      Test implementation
                                            Developer   Tester




Thursday, August 16, 12
tester / quality analyst
   ...is a role, not a person

   ...is not a failed developer

   ...advocates for the user and makes the quality of the
   system transparent
   ...should not be primarily working on manual
   regression testing
   ...should be focussed on exploratory testing &
   maintaining automated acceptance tests
Thursday, August 16, 12
remember

                 passing acceptance tests are necessary (but
                 insufficient) for “done”


                 encapsulate!



                 the acceptance tests are owned by - and the
                 responsibility of - the team
Thursday, August 16, 12
principle 2


        always interact with the system
        under test the same way a user
        would




Thursday, August 16, 12
browser based tests are unreliable

   "the test fails in CI, but when I run the app,
   everything seems fine"

  usually an indication that test mechanics and user
  interaction patterns differ

   ajax based tests?

   JS heavy applications, which need non-zero
   processing time to modify the UI
Thursday, August 16, 12
some solutions

   Test your application the way a user might use it.

   Understand when behavior is asynchronous and
   account for it explicitly

   Don’t use bare sleeps: poll

   If it’s hard to write the test, you need to have a
   conversation with the team

Thursday, August 16, 12
some solutions


    wait-utils (https://github.com/itspanzi/WaitUtils)



    for ajax tests, if your JS framework provides a pre-
    and post-call hook, intercept those to count the
    number of active calls before proceeding



Thursday, August 16, 12
var AjaxTracker = {                                                      https://gist.github.com/3315690

     PENDING_REQUESTS: $A([]),

     onCreate: function(request){
        if (!request.url.match(/gadgets/js//)) {
          this.PENDING_REQUESTS.push(request.url);
        }
     },

     onComplete: function(request){
        this.PENDING_REQUESTS = this.PENDING_REQUESTS.without(request.url);
     },

     onException: function(request, exception){
        try {
          this.onComplete(request);
        }catch(e){
          if (Prototype.isFireBugsEnabled) {
            console.log("Got Exception on request: " + request.url);
            console.log(e);
            throw(e);
          }
        }
     },

     allAjaxComplete: function(includeCardSummary){
       var requests = this.PENDING_REQUESTS.reject(function(url) {
           return url.match(/cards/card_summary/) || url.match(/also_viewing/);
         });
       return requests.size() == 0;
     }
};

Ajax.Responders.register(AjaxTracker);

Thursday, August 16, 12
remember

                 make time to go back and refactor your
                 tests


                 use layers and encapsulation: separate high
                 level intent and low level mechanics


                 use page object to interact with SUT; run
                 against service layer where possible
Thursday, August 16, 12
principle 3


        continuously curate the structure
        of your test suites




Thursday, August 16, 12
#1312
             #1301                                                                                              As a... I want... So that...
             As a... I want... So that...                                      #1310
                                                                               As a... I want... So that...     Given...       Given...
             Given...           Given...    #1306                                                               When...        When...
             When...            When...     As a... I want... So that...                                        Then...        Then...
                                                                               Given...      Given...
             Then...            Then...                                        When...     #1304
                                                                                             When...
                          #1315             Given...       Given...                        AsThen...
                                                                                              a... I want... So that...
                                                                               Then...
                                            When...        When...
                          As a... I want... So that...
                                            Then...        Then...                      Given...          Given...
                     Given...       Given...                      #1308                 When...           When...
                     When...        When...                       As a... I want... So that...
                                                                                        Then...           Then...
           #1307 Then...           Then...                                                                      #1313
           As a... I want... So that...                         Given...           Given...                    As a... I want... So that...
                                             #1317              When...            When...
                                                                                   Then...#1311
                                              As a... I want... Then...
                                                                So that...
           Given...           Given... #1303                                                                   Given...       Given...
           When...            When... As a... Given... So that...                         As a... I want... So When...
                                                                                                               that...        When...
                                               I want...     Given...
           Then...            Then...         When...        When...                                           Then...         Then...
                                                                                           Given...       Given...
                                       Given...
                                              Then... Given...
                                                             Then...                       When...        When...
                                       When...        When...
                                                                                           Then...        Then...
                                       Then...       Then...
                                                         #1305
                #1309                                    As a... I want... So that...                  #1302
                As a... I want... So that...                                                           As a... I want... So that...
                                                                             #1318
                                                         Given...          Given... I want... So that...
                Given...              #1316
                                   Given...              When...
                                                                            As a...
                                                                           When...                     Given... #1314Given...
                When...               As a... I want... So that...
                                   When...                                                             When... As a... I want... So that...
                                                                                                                     When...
                                                         Then...           Then...
                                                                            Given...       Given... Then...
                Then...            Then...                                                                          Then...
                                      Given...       Given...               When...        When...              Given...      Given...
                                      When...        When...                Then...       Then...               When...       When...
                                      Then...       Then...                                                     Then...       Then...



Thursday, August 16, 12
journey tests

                                     #1612
                                     As a customer
                                     I want a gift wrapping option
                                     So that I don’t have to wrap
    Buy Product                      them and post them myself       Buy Product

    Search product catalogue                                         Search product catalogue
    Add product to cart                                              Add product to cart
    Check out                                                        Check out
    Create new account                                               Create new account
    Provide address details                                          Provide address details
    Provide credit card details                                      Provide credit card details
    Complete order                                                   Select gift wrapping option
    Verify order created                                             Complete order
    Verify credit card debited                                       Verify order created
    Verify email sent                                                Verify gift wrapping option
                                                                     Verify credit card debited
                                                                     Verify email sent

Thursday, August 16, 12
some solutions

   identify user journeys

   ( journey: the path a persona takes through the
   application to achieve an end goal)

   most applications have very few distinct personas

   most stories in iterative development are
   enhancements to existing journeys
Thursday, August 16, 12
features
  Basic shopping cart functionality

  Searching for a product
  - searching for a word should bring up all products which have that word in their name
  - searching for a phrase should bring up all products which have any of the words in their
  name
  - searching for a quoted phrase should bring up all products which have all words in the
  the quoted phrase in their name

  Paginating search results
  - return 25 results per page by default
  - if there are fewer than 25 results, do not show pagination links
  - provide a "previous" link on every page other than the first page of results
  - provide a "next" link on every page other than the last page of results
  - if user supplies a page number which is less than 1 in the URL, stay on the first page
  - if the user supplies a page number greater than the last page of results, stay on the
  last page

  Gift-wrap option




Thursday, August 16, 12
story tests
    Story tests for search
    - test that searching for "friends" brings back 782 results
    -- results should include how to win friends and influence people

    - test that searching for dead friends brings back 8900 results
    -- results should include <how to win friends and influence people>
    -- results should include <The Zombie Survival Guide: Complete Protection from the
    Living Dead>

    - test that searching for "dead friends" brings back 57 results
    -- results should include <all my friends are dead>

    Story tests for pagination
    - with a catalog of 3 products, I should see no pagination links
    - with a catalog of 25 products, I should see no pagination links
    - with a catalog of 26 products, I should see 1 link to page two, along with a next link
    but no previous link
    - with a catalog of 26 products, on page 2, I should see one product, with a link to
    page one, a previous link but no next link

    Story tests for gift wrapping




Thursday, August 16, 12
journey tests
    Journey of user buying a book

    - Login as user "bob"
    - Search for <"my friends" dead>
    - Make sure that 3 pages of results show
    - Verify that "All My Friends Are Dead" by "Avery Monson" is on
    the first page
    - Add two copies of the book to the shopping cart
    - Gift wrap one of them
    - Proceed to checkout




Thursday, August 16, 12
more solutions

   extract journeys from your acceptance tests

   make them fast and run them first

   do test the most likely path that the team, business
   and UX folk agree upon

   do not test every possible path through the system

   extract negative tests and edge cases into a
   regression suite which runs after your journey tests
Thursday, August 16, 12
build quality in
                               “Cease dependence on
                               mass inspection to achieve
                               quality. Improve the
                               process and build quality
                               into the product in the first
                               place”

                                  W. Edwards Deming
Thursday, August 16, 12
why cross-functional teams?
   output of testing is not just bug reports


   feedback from testing to product design


   feedback from test framework to system architecture


   developers and testers share knowledge and skills

Thursday, August 16, 12
principle 4


        everyone owns acceptance tests




Thursday, August 16, 12
when acceptance tests break
                 Triage to find root cause
                     1. There was an environmental problem
                     2. There is a bug with the test
                     3. An assumption changed
                     4. The test actually caught a bug
                 Fix the problem
                 Add a guard to prevent it happening again
                 Optimise your test suite: detect failures fast
                 Optimise your process for time to fix tests
Thursday, August 16, 12
intermittent failures


                 flaky tests are worse than useless



                 quarantine flaky tests - but not forever


                 http://martinfowler.com/articles/
                 nonDeterminism.html
Thursday, August 16, 12
external systems

   not all tests should call the external system



   parameterize connections to external systems



   Run integration smoke tests before full
   acceptance suite

Thursday, August 16, 12
impersonator pattern

   create a proxy from SUT to external system

   cache results from integration smoke tests

   run integration smoke tests before acceptance suite

   periodically expire cache

   only run acceptance suite if integration smoke tests
   pass!
Thursday, August 16, 12
principle 5


        acceptance tests are responsible
        for managing their own test data




Thursday, August 16, 12
test data

   Test-specific data

   Test reference data

   Application reference data

   Ensure tests are independent

   Don’t use production data dumps (except for
   performance testing and staging)
Thursday, August 16, 12
recap
        1. treat acceptance tests like production code

        2. always interact with the SUT like a user would

        3. continuously curate your user journeys

        4. collective ownership of acceptance tests

        5. acceptance tests own their data




Thursday, August 16, 12
take-aways
        • quality is everybody’s responsibility

        • high quality test suites are continuously curated
          - by testers and developers working together

        • test code needs to receive the same care as
          production code

        • exhaustive story-level testing is not a good
          basis for maintainable acceptance suites



Thursday, August 16, 12
questions

        @badrij | badri@thoughtworks.com
        @jezhumble | jez@thoughtworks.com

        http://continuousdelivery.com/




                                                             © 2011 ThoughtWorks, Inc.


                          http://thoughtworks-studios.com/
Thursday, August 16, 12

Contenu connexe

Tendances

Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)David Ehringer
 
Cypress first impressions
Cypress first impressionsCypress first impressions
Cypress first impressionsHans Emmel
 
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)Mr. Vengineer
 
Vagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptopVagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptopLorin Hochstein
 
[KGC 2011]Boost 라이브러리와 C++11
[KGC 2011]Boost 라이브러리와 C++11[KGC 2011]Boost 라이브러리와 C++11
[KGC 2011]Boost 라이브러리와 C++11흥배 최
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerPriyank Kapadia
 
Introduction cypress
Introduction cypressIntroduction cypress
Introduction cypressOim Trust
 
Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringGeorg Schönberger
 
Ansible勉強会資料
Ansible勉強会資料Ansible勉強会資料
Ansible勉強会資料Makoto Oya
 
e2e testing with cypress
e2e testing with cypresse2e testing with cypress
e2e testing with cypressTomasz Bak
 
Develop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM BoardsDevelop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM BoardsNational Cheng Kung University
 
Seastore: Next Generation Backing Store for Ceph
Seastore: Next Generation Backing Store for CephSeastore: Next Generation Backing Store for Ceph
Seastore: Next Generation Backing Store for CephScyllaDB
 
One-Liners to Rule Them All
One-Liners to Rule Them AllOne-Liners to Rule Them All
One-Liners to Rule Them Allegypt
 
How to Get Started with Cypress
How to Get Started with CypressHow to Get Started with Cypress
How to Get Started with CypressApplitools
 
Working Remotely (via SSH) Rocks!
Working Remotely (via SSH) Rocks!Working Remotely (via SSH) Rocks!
Working Remotely (via SSH) Rocks!Kent Chen
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDBLinaro
 
自動でバグを見つける!プログラム解析と動的バイナリ計装
自動でバグを見つける!プログラム解析と動的バイナリ計装自動でバグを見つける!プログラム解析と動的バイナリ計装
自動でバグを見つける!プログラム解析と動的バイナリ計装uchan_nos
 
Broken Linux Performance Tools 2016
Broken Linux Performance Tools 2016Broken Linux Performance Tools 2016
Broken Linux Performance Tools 2016Brendan Gregg
 

Tendances (20)

Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)
 
Cypress first impressions
Cypress first impressionsCypress first impressions
Cypress first impressions
 
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
ZynqMPのブートとパワーマネージメント : (ZynqMP Boot and Power Management)
 
Vagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptopVagrant, Ansible, and OpenStack on your laptop
Vagrant, Ansible, and OpenStack on your laptop
 
[KGC 2011]Boost 라이브러리와 C++11
[KGC 2011]Boost 라이브러리와 C++11[KGC 2011]Boost 라이브러리와 C++11
[KGC 2011]Boost 라이브러리와 C++11
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU Debugger
 
Introduction cypress
Introduction cypressIntroduction cypress
Introduction cypress
 
Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and Monitoring
 
Ansible勉強会資料
Ansible勉強会資料Ansible勉強会資料
Ansible勉強会資料
 
e2e testing with cypress
e2e testing with cypresse2e testing with cypress
e2e testing with cypress
 
Develop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM BoardsDevelop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM Boards
 
Seastore: Next Generation Backing Store for Ceph
Seastore: Next Generation Backing Store for CephSeastore: Next Generation Backing Store for Ceph
Seastore: Next Generation Backing Store for Ceph
 
One-Liners to Rule Them All
One-Liners to Rule Them AllOne-Liners to Rule Them All
One-Liners to Rule Them All
 
How to Get Started with Cypress
How to Get Started with CypressHow to Get Started with Cypress
How to Get Started with Cypress
 
Working Remotely (via SSH) Rocks!
Working Remotely (via SSH) Rocks!Working Remotely (via SSH) Rocks!
Working Remotely (via SSH) Rocks!
 
SSH力をつけよう
SSH力をつけようSSH力をつけよう
SSH力をつけよう
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDB
 
Component testing with cypress
Component testing with cypressComponent testing with cypress
Component testing with cypress
 
自動でバグを見つける!プログラム解析と動的バイナリ計装
自動でバグを見つける!プログラム解析と動的バイナリ計装自動でバグを見つける!プログラム解析と動的バイナリ計装
自動でバグを見つける!プログラム解析と動的バイナリ計装
 
Broken Linux Performance Tools 2016
Broken Linux Performance Tools 2016Broken Linux Performance Tools 2016
Broken Linux Performance Tools 2016
 

En vedette

How Spotify Does Test Automation - Kristian Karl
How Spotify Does Test Automation - Kristian KarlHow Spotify Does Test Automation - Kristian Karl
How Spotify Does Test Automation - Kristian KarlSmartBear
 
Quality Built In @ Spotify
Quality Built In @ SpotifyQuality Built In @ Spotify
Quality Built In @ SpotifyAndrii Dzynia
 
Ross Snyder, Etsy, SXSW Lean Startup 2013
Ross Snyder, Etsy, SXSW Lean Startup 2013Ross Snyder, Etsy, SXSW Lean Startup 2013
Ross Snyder, Etsy, SXSW Lean Startup 2013500 Startups
 
Tips for Designing, Testing & Delivering eLearning in a Multi-device World
Tips for Designing, Testing & Delivering eLearning in a Multi-device WorldTips for Designing, Testing & Delivering eLearning in a Multi-device World
Tips for Designing, Testing & Delivering eLearning in a Multi-device WorldUpside Learning Solutions
 
Introduction to SoapUI day 1
Introduction to SoapUI day 1Introduction to SoapUI day 1
Introduction to SoapUI day 1Qualitest
 
Introduction to Test Automation
Introduction to Test AutomationIntroduction to Test Automation
Introduction to Test AutomationPekka Klärck
 
Continuous Delivery Sounds Great but it Won't Work Here
Continuous Delivery Sounds Great but it Won't Work HereContinuous Delivery Sounds Great but it Won't Work Here
Continuous Delivery Sounds Great but it Won't Work HereJez Humble
 
Applying the Lean Startup Model to the Enterprise
Applying the Lean Startup Model to the EnterpriseApplying the Lean Startup Model to the Enterprise
Applying the Lean Startup Model to the EnterpriseJez Humble
 
Devops Scorecard
Devops ScorecardDevops Scorecard
Devops ScorecardJez Humble
 
Selenium Users Anonymous
Selenium Users AnonymousSelenium Users Anonymous
Selenium Users AnonymousDave Haeffner
 
Continuous Delivery
Continuous DeliveryContinuous Delivery
Continuous DeliveryMike McGarr
 
Test coaching your agile team
Test coaching your agile teamTest coaching your agile team
Test coaching your agile teamAndrii Dzynia
 
What is the best way to measure progress on an Agile project?
What is the best way to measure progress on an Agile project?What is the best way to measure progress on an Agile project?
What is the best way to measure progress on an Agile project?ThoughtWorks Studios
 
Building Real-Time Web Applications
Building Real-Time Web ApplicationsBuilding Real-Time Web Applications
Building Real-Time Web ApplicationsTony Abou-Assaleh
 
HTML5 WebSockets in Python/Django
HTML5 WebSockets in Python/DjangoHTML5 WebSockets in Python/Django
HTML5 WebSockets in Python/DjangoTony Abou-Assaleh
 
QA процесс, часть 2
QA процесс, часть 2QA процесс, часть 2
QA процесс, часть 2DressTester
 

En vedette (18)

How Spotify Does Test Automation - Kristian Karl
How Spotify Does Test Automation - Kristian KarlHow Spotify Does Test Automation - Kristian Karl
How Spotify Does Test Automation - Kristian Karl
 
Quality Built In @ Spotify
Quality Built In @ SpotifyQuality Built In @ Spotify
Quality Built In @ Spotify
 
Ross Snyder, Etsy, SXSW Lean Startup 2013
Ross Snyder, Etsy, SXSW Lean Startup 2013Ross Snyder, Etsy, SXSW Lean Startup 2013
Ross Snyder, Etsy, SXSW Lean Startup 2013
 
Tips for Designing, Testing & Delivering eLearning in a Multi-device World
Tips for Designing, Testing & Delivering eLearning in a Multi-device WorldTips for Designing, Testing & Delivering eLearning in a Multi-device World
Tips for Designing, Testing & Delivering eLearning in a Multi-device World
 
Introduction to SoapUI day 1
Introduction to SoapUI day 1Introduction to SoapUI day 1
Introduction to SoapUI day 1
 
Introduction to Test Automation
Introduction to Test AutomationIntroduction to Test Automation
Introduction to Test Automation
 
Continuous Delivery Sounds Great but it Won't Work Here
Continuous Delivery Sounds Great but it Won't Work HereContinuous Delivery Sounds Great but it Won't Work Here
Continuous Delivery Sounds Great but it Won't Work Here
 
Applying the Lean Startup Model to the Enterprise
Applying the Lean Startup Model to the EnterpriseApplying the Lean Startup Model to the Enterprise
Applying the Lean Startup Model to the Enterprise
 
Devops Scorecard
Devops ScorecardDevops Scorecard
Devops Scorecard
 
Selenium Users Anonymous
Selenium Users AnonymousSelenium Users Anonymous
Selenium Users Anonymous
 
Continuous Delivery
Continuous DeliveryContinuous Delivery
Continuous Delivery
 
Test coaching your agile team
Test coaching your agile teamTest coaching your agile team
Test coaching your agile team
 
What is the best way to measure progress on an Agile project?
What is the best way to measure progress on an Agile project?What is the best way to measure progress on an Agile project?
What is the best way to measure progress on an Agile project?
 
When qa sucks
When qa sucksWhen qa sucks
When qa sucks
 
RTSJ
RTSJRTSJ
RTSJ
 
Building Real-Time Web Applications
Building Real-Time Web ApplicationsBuilding Real-Time Web Applications
Building Real-Time Web Applications
 
HTML5 WebSockets in Python/Django
HTML5 WebSockets in Python/DjangoHTML5 WebSockets in Python/Django
HTML5 WebSockets in Python/Django
 
QA процесс, часть 2
QA процесс, часть 2QA процесс, часть 2
QA процесс, часть 2
 

Similaire à Creating Maintainable Automated Acceptance Tests

Java Course 6: Introduction to Agile
Java Course 6: Introduction to AgileJava Course 6: Introduction to Agile
Java Course 6: Introduction to AgileAnton Keks
 
Quality assurance in distributed continuous delivery
Quality assurance in distributed continuous deliveryQuality assurance in distributed continuous delivery
Quality assurance in distributed continuous deliverymingjin
 
Agile Testing 2020
Agile Testing 2020Agile Testing 2020
Agile Testing 2020arzu TR
 
Agile Java Testing With Open Source Frameworks
Agile Java Testing With Open Source FrameworksAgile Java Testing With Open Source Frameworks
Agile Java Testing With Open Source FrameworksViraf Karai
 
Software Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails ApplicationsSoftware Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails ApplicationsBhavin Javia
 
Test Automation Frameworks: Assumptions, Concepts & Tools
Test Automation Frameworks: Assumptions, Concepts & ToolsTest Automation Frameworks: Assumptions, Concepts & Tools
Test Automation Frameworks: Assumptions, Concepts & ToolsAmit Rawat
 
RahulAnand_Testing_5.9years_exp_CV
RahulAnand_Testing_5.9years_exp_CVRahulAnand_Testing_5.9years_exp_CV
RahulAnand_Testing_5.9years_exp_CVRahul Anand
 
Software Testing
Software TestingSoftware Testing
Software TestingAdroitLogic
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentJohn Blum
 
Continuous delivery agile_2012
Continuous delivery agile_2012Continuous delivery agile_2012
Continuous delivery agile_2012drewz lin
 
Test automation - Building effective solutions
Test automation - Building effective solutionsTest automation - Building effective solutions
Test automation - Building effective solutionsArtem Nagornyi
 
Agile testing - Principles and best practices
Agile testing  - Principles and best practicesAgile testing  - Principles and best practices
Agile testing - Principles and best practicesDr Ganesh Iyer
 
7 Deadly Sins of Agile Software Test Automation
7 Deadly Sins of Agile Software Test Automation7 Deadly Sins of Agile Software Test Automation
7 Deadly Sins of Agile Software Test AutomationAdrian Smith
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsAbhijeet Vaikar
 
Continuous Security Testing
Continuous Security TestingContinuous Security Testing
Continuous Security TestingSteven Mak
 
Test Driven Development Introduction
Test Driven Development IntroductionTest Driven Development Introduction
Test Driven Development IntroductionNguyen Hai
 
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecampIasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecampCodecamp Romania
 
Appium workshop technopark trivandrum
Appium workshop technopark trivandrumAppium workshop technopark trivandrum
Appium workshop technopark trivandrumSyam Sasi
 
Webinar: Estrategias para optimizar los costos de testing
Webinar: Estrategias para optimizar los costos de testingWebinar: Estrategias para optimizar los costos de testing
Webinar: Estrategias para optimizar los costos de testingFederico Toledo
 

Similaire à Creating Maintainable Automated Acceptance Tests (20)

Java Course 6: Introduction to Agile
Java Course 6: Introduction to AgileJava Course 6: Introduction to Agile
Java Course 6: Introduction to Agile
 
Quality assurance in distributed continuous delivery
Quality assurance in distributed continuous deliveryQuality assurance in distributed continuous delivery
Quality assurance in distributed continuous delivery
 
Agile Testing 2020
Agile Testing 2020Agile Testing 2020
Agile Testing 2020
 
Agile Java Testing With Open Source Frameworks
Agile Java Testing With Open Source FrameworksAgile Java Testing With Open Source Frameworks
Agile Java Testing With Open Source Frameworks
 
Software Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails ApplicationsSoftware Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails Applications
 
Test Automation Frameworks: Assumptions, Concepts & Tools
Test Automation Frameworks: Assumptions, Concepts & ToolsTest Automation Frameworks: Assumptions, Concepts & Tools
Test Automation Frameworks: Assumptions, Concepts & Tools
 
RahulAnand_Testing_5.9years_exp_CV
RahulAnand_Testing_5.9years_exp_CVRahulAnand_Testing_5.9years_exp_CV
RahulAnand_Testing_5.9years_exp_CV
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Continuous delivery agile_2012
Continuous delivery agile_2012Continuous delivery agile_2012
Continuous delivery agile_2012
 
Test automation - Building effective solutions
Test automation - Building effective solutionsTest automation - Building effective solutions
Test automation - Building effective solutions
 
Agile testing - Principles and best practices
Agile testing  - Principles and best practicesAgile testing  - Principles and best practices
Agile testing - Principles and best practices
 
7 Deadly Sins of Agile Software Test Automation
7 Deadly Sins of Agile Software Test Automation7 Deadly Sins of Agile Software Test Automation
7 Deadly Sins of Agile Software Test Automation
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium tests
 
Continuous Security Testing
Continuous Security TestingContinuous Security Testing
Continuous Security Testing
 
Test Driven Development Introduction
Test Driven Development IntroductionTest Driven Development Introduction
Test Driven Development Introduction
 
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecampIasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
 
Appium workshop technopark trivandrum
Appium workshop technopark trivandrumAppium workshop technopark trivandrum
Appium workshop technopark trivandrum
 
Webinar: Estrategias para optimizar los costos de testing
Webinar: Estrategias para optimizar los costos de testingWebinar: Estrategias para optimizar los costos de testing
Webinar: Estrategias para optimizar los costos de testing
 
Integration testing - A&BP CC
Integration testing - A&BP CCIntegration testing - A&BP CC
Integration testing - A&BP CC
 

Dernier

Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 

Dernier (20)

Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 

Creating Maintainable Automated Acceptance Tests

  • 1. Maintainable Acceptance Tests Badrinath Janakiraman Jez Humble Agile 2012 Dallas @badrij | badri@thoughtworks.com @jezhumble | jez@thoughtworks.com http://thoughtworks-studios.com/ Thursday, August 16, 12
  • 2. what to expect • Creating high quality acceptance tests • How to structure a maintainable acceptance test suite • Patterns for effective teamwork • Managing test data Thursday, August 16, 12
  • 3. what to take away • Quality is everybody’s responsibility • High quality test suites are continuously curated - by testers and developers working together • Test code needs to receive the same care as production code • Exhaustive story-level testing is not a good basis for maintainable acceptance suites Thursday, August 16, 12
  • 4. different kinds of tests Business facing AUTOMATED MANUAL Showcases Support programming Functional acceptance Usability testing tests Critique project Exploratory testing Unit tests Non-functional Integration tests acceptance tests System tests (performance, scaling, ...) AUTOMATED MANUAL / AUTOMATED Technology facing Diagram invented by Brian Marick Thursday, August 16, 12
  • 5. UI Mike Cohn: Succeeding with Agile Service Unit Thursday, August 16, 12
  • 6. End to End Business Facing Localized Technology Facing Thursday, August 16, 12
  • 7. principle 0 Writing good acceptance tests is hard. (good: when the tests are green, we know the software works) Thursday, August 16, 12
  • 8. mingle 2006 2012 20 tests 3000 tests 500 LOC 50k LOC 2 minutes 12 hours • actual running time: 55 minutes • 7-10 times a day • for 6 years, across 4 offices now Thursday, August 16, 12
  • 9. why do test suites decay? for the same reasons code does we don’t pay enough attention to expressing intent only testers care about maintaining tests Thursday, August 16, 12
  • 11. principle 1 Tests are first-class citizens of your project Thursday, August 16, 12
  • 12. preventing decay in test code treat test code as production c0de refactor relentlessly don’t repeat yourself don’t repeat yourself use record-playback tools to build your suite Thursday, August 16, 12
  • 13. preventing decay of intention given-when-then is insufficient separate intention from mechanics express the test as steps of a user's journey Thursday, August 16, 12
  • 14. a solution use natural language to express intentions use a general purpose programming language to express test mechanics use a tool that allows you to operate in either domain transparently Thursday, August 16, 12
  • 16. page object https://gist.github.com/3345556 public class LoginPage { private final SeleniumSession browser; public LoginPage(Selenium browser){ this.browser = browser; } public HomePage loginAs(String user, String password){ browser.type('#login', login); browser.type('#password', password); browser.submit('#login-form'); return new HomePage(this.browser); } public HomePage loginExpectingError(String user, String password){ browser.type('#login', login); browser.type('#password', password); browser.submit('#login-form'); return new LoginPage(this.browser); } } Thursday, August 16, 12
  • 17. Acceptance Criteria Customer Tester Test implementation Developer Tester Thursday, August 16, 12
  • 18. tester / quality analyst ...is a role, not a person ...is not a failed developer ...advocates for the user and makes the quality of the system transparent ...should not be primarily working on manual regression testing ...should be focussed on exploratory testing & maintaining automated acceptance tests Thursday, August 16, 12
  • 19. remember passing acceptance tests are necessary (but insufficient) for “done” encapsulate! the acceptance tests are owned by - and the responsibility of - the team Thursday, August 16, 12
  • 20. principle 2 always interact with the system under test the same way a user would Thursday, August 16, 12
  • 21. browser based tests are unreliable "the test fails in CI, but when I run the app, everything seems fine" usually an indication that test mechanics and user interaction patterns differ ajax based tests? JS heavy applications, which need non-zero processing time to modify the UI Thursday, August 16, 12
  • 22. some solutions Test your application the way a user might use it. Understand when behavior is asynchronous and account for it explicitly Don’t use bare sleeps: poll If it’s hard to write the test, you need to have a conversation with the team Thursday, August 16, 12
  • 23. some solutions wait-utils (https://github.com/itspanzi/WaitUtils) for ajax tests, if your JS framework provides a pre- and post-call hook, intercept those to count the number of active calls before proceeding Thursday, August 16, 12
  • 24. var AjaxTracker = { https://gist.github.com/3315690 PENDING_REQUESTS: $A([]), onCreate: function(request){ if (!request.url.match(/gadgets/js//)) { this.PENDING_REQUESTS.push(request.url); } }, onComplete: function(request){ this.PENDING_REQUESTS = this.PENDING_REQUESTS.without(request.url); }, onException: function(request, exception){ try { this.onComplete(request); }catch(e){ if (Prototype.isFireBugsEnabled) { console.log("Got Exception on request: " + request.url); console.log(e); throw(e); } } }, allAjaxComplete: function(includeCardSummary){ var requests = this.PENDING_REQUESTS.reject(function(url) { return url.match(/cards/card_summary/) || url.match(/also_viewing/); }); return requests.size() == 0; } }; Ajax.Responders.register(AjaxTracker); Thursday, August 16, 12
  • 25. remember make time to go back and refactor your tests use layers and encapsulation: separate high level intent and low level mechanics use page object to interact with SUT; run against service layer where possible Thursday, August 16, 12
  • 26. principle 3 continuously curate the structure of your test suites Thursday, August 16, 12
  • 27. #1312 #1301 As a... I want... So that... As a... I want... So that... #1310 As a... I want... So that... Given... Given... Given... Given... #1306 When... When... When... When... As a... I want... So that... Then... Then... Given... Given... Then... Then... When... #1304 When... #1315 Given... Given... AsThen... a... I want... So that... Then... When... When... As a... I want... So that... Then... Then... Given... Given... Given... Given... #1308 When... When... When... When... As a... I want... So that... Then... Then... #1307 Then... Then... #1313 As a... I want... So that... Given... Given... As a... I want... So that... #1317 When... When... Then...#1311 As a... I want... Then... So that... Given... Given... #1303 Given... Given... When... When... As a... Given... So that... As a... I want... So When... that... When... I want... Given... Then... Then... When... When... Then... Then... Given... Given... Given... Then... Given... Then... When... When... When... When... Then... Then... Then... Then... #1305 #1309 As a... I want... So that... #1302 As a... I want... So that... As a... I want... So that... #1318 Given... Given... I want... So that... Given... #1316 Given... When... As a... When... Given... #1314Given... When... As a... I want... So that... When... When... As a... I want... So that... When... Then... Then... Given... Given... Then... Then... Then... Then... Given... Given... When... When... Given... Given... When... When... Then... Then... When... When... Then... Then... Then... Then... Thursday, August 16, 12
  • 28. journey tests #1612 As a customer I want a gift wrapping option So that I don’t have to wrap Buy Product them and post them myself Buy Product Search product catalogue Search product catalogue Add product to cart Add product to cart Check out Check out Create new account Create new account Provide address details Provide address details Provide credit card details Provide credit card details Complete order Select gift wrapping option Verify order created Complete order Verify credit card debited Verify order created Verify email sent Verify gift wrapping option Verify credit card debited Verify email sent Thursday, August 16, 12
  • 29. some solutions identify user journeys ( journey: the path a persona takes through the application to achieve an end goal) most applications have very few distinct personas most stories in iterative development are enhancements to existing journeys Thursday, August 16, 12
  • 30. features Basic shopping cart functionality Searching for a product - searching for a word should bring up all products which have that word in their name - searching for a phrase should bring up all products which have any of the words in their name - searching for a quoted phrase should bring up all products which have all words in the the quoted phrase in their name Paginating search results - return 25 results per page by default - if there are fewer than 25 results, do not show pagination links - provide a "previous" link on every page other than the first page of results - provide a "next" link on every page other than the last page of results - if user supplies a page number which is less than 1 in the URL, stay on the first page - if the user supplies a page number greater than the last page of results, stay on the last page Gift-wrap option Thursday, August 16, 12
  • 31. story tests Story tests for search - test that searching for "friends" brings back 782 results -- results should include how to win friends and influence people - test that searching for dead friends brings back 8900 results -- results should include <how to win friends and influence people> -- results should include <The Zombie Survival Guide: Complete Protection from the Living Dead> - test that searching for "dead friends" brings back 57 results -- results should include <all my friends are dead> Story tests for pagination - with a catalog of 3 products, I should see no pagination links - with a catalog of 25 products, I should see no pagination links - with a catalog of 26 products, I should see 1 link to page two, along with a next link but no previous link - with a catalog of 26 products, on page 2, I should see one product, with a link to page one, a previous link but no next link Story tests for gift wrapping Thursday, August 16, 12
  • 32. journey tests Journey of user buying a book - Login as user "bob" - Search for <"my friends" dead> - Make sure that 3 pages of results show - Verify that "All My Friends Are Dead" by "Avery Monson" is on the first page - Add two copies of the book to the shopping cart - Gift wrap one of them - Proceed to checkout Thursday, August 16, 12
  • 33. more solutions extract journeys from your acceptance tests make them fast and run them first do test the most likely path that the team, business and UX folk agree upon do not test every possible path through the system extract negative tests and edge cases into a regression suite which runs after your journey tests Thursday, August 16, 12
  • 34. build quality in “Cease dependence on mass inspection to achieve quality. Improve the process and build quality into the product in the first place” W. Edwards Deming Thursday, August 16, 12
  • 35. why cross-functional teams? output of testing is not just bug reports feedback from testing to product design feedback from test framework to system architecture developers and testers share knowledge and skills Thursday, August 16, 12
  • 36. principle 4 everyone owns acceptance tests Thursday, August 16, 12
  • 37. when acceptance tests break Triage to find root cause 1. There was an environmental problem 2. There is a bug with the test 3. An assumption changed 4. The test actually caught a bug Fix the problem Add a guard to prevent it happening again Optimise your test suite: detect failures fast Optimise your process for time to fix tests Thursday, August 16, 12
  • 38. intermittent failures flaky tests are worse than useless quarantine flaky tests - but not forever http://martinfowler.com/articles/ nonDeterminism.html Thursday, August 16, 12
  • 39. external systems not all tests should call the external system parameterize connections to external systems Run integration smoke tests before full acceptance suite Thursday, August 16, 12
  • 40. impersonator pattern create a proxy from SUT to external system cache results from integration smoke tests run integration smoke tests before acceptance suite periodically expire cache only run acceptance suite if integration smoke tests pass! Thursday, August 16, 12
  • 41. principle 5 acceptance tests are responsible for managing their own test data Thursday, August 16, 12
  • 42. test data Test-specific data Test reference data Application reference data Ensure tests are independent Don’t use production data dumps (except for performance testing and staging) Thursday, August 16, 12
  • 43. recap 1. treat acceptance tests like production code 2. always interact with the SUT like a user would 3. continuously curate your user journeys 4. collective ownership of acceptance tests 5. acceptance tests own their data Thursday, August 16, 12
  • 44. take-aways • quality is everybody’s responsibility • high quality test suites are continuously curated - by testers and developers working together • test code needs to receive the same care as production code • exhaustive story-level testing is not a good basis for maintainable acceptance suites Thursday, August 16, 12
  • 45. questions @badrij | badri@thoughtworks.com @jezhumble | jez@thoughtworks.com http://continuousdelivery.com/ © 2011 ThoughtWorks, Inc. http://thoughtworks-studios.com/ Thursday, August 16, 12