Functional Test Refactoring

Similar documents
Practical Web Test Automation

SELENIUM WEBDRIVER RECIPES IN C#: SECOND EDITION BY ZHIMIN ZHAN DOWNLOAD EBOOK : SELENIUM WEBDRIVER RECIPES IN C#: SECOND EDITION BY ZHIMIN ZHAN PDF

Applying modern software development techniques to UI testing

Standards New Zealand Online Library user guide for Read-Only users Logging in as a Read-Only user

SELENIUM WEBDRIVER RECIPES IN PYTHON: THE PROBLEM SOLVING GUIDE TO SELENIUM WEBDRIVER IN PYTHON (TEST RECIPES SERIES) (VOLUME 5) BY ZHIMI

Standards New Zealand

SELENIUM WEBDRIVER RECIPES IN PYTHON: THE PROBLEM SOLVING GUIDE TO SELENIUM WEBDRIVER IN PYTHON (TEST RECIPES SERIES) (VOLUME 5) BY ZHIMI

EducoSoft. Student Registration

Acceptance Testing. Copyright 2012 Gary Mohan.

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

The Power of Unit Testing and it s impact on your business. Ashish Kumar Vice President, Engineering

How to Use Your EV Connect Account

Test Automation. Fundamentals. Mikó Szilárd

Why test automation projects are failing? Igor Khrol

Demo Lab Guide TechDirect

Software Engineering I (02161)

Fundraising for SKiP

A few more things about Agile and SE. Could help in interviews, but don t try to bluff your way through

Efficient Test Automation on an Agile Project

Accessing Personnel Info & Payslips

Software Engineering I (02161)

AGILE DATABASE TECHNIQUES USING VISUAL STUDIO TEAM SYSTEM 2008 Course ADT08: Three days; Instructor-Led Course Syllabus INTRODUCTION AUDIENCE

CS 577A Team 1 DCR ARB. PicShare

Applicant Coupling. Users: Main Residency Match Applicants Fellowship Match Applicants

Master Every Stage of Your Mobile App Lifecycle: Micro Focus Mobile Center. Brochure. Application Development, Test & Delivery

MOBILE BANKING APPLICATION USER GUIDE

Premier Club Member Online Booking Guide Page 1

XP: Planning, coding and testing. Planning. Release planning. Release Planning. User stories. Release planning Step 1.

XP: Planning, coding and testing. Practice Planning game. Release Planning. User stories. Annika Silvervarg

Applicant Coupling. Users: Main Residency Match Applicants Fellowship Match Applicants

A Tale of Continuous Testing

For other details about the campaign including Frequently Asked Questions, please visit

STaR Chart Basics (For Teachers & Librarians)

HOW TO WRITE USER STORIES (AND WHAT YOU SHOULD NOT DO) Stuart Ashman, QA Director at Mio Global Bob Cook, Senior Product Development Manager, Sophos

02291: System Integration

Registration Guide to World Masters - Individuals and small groups

Introduction to Extreme Programming

1. Contents Getting Started Registering as a New User Logging in Using Re*Book for the first time...

Test-driven development

Agile vs Fragile. Susmit Bhattacharya, Solution Architect, Asia Pacific. - The need for Automation in Agile Tricentis GmbH. All Rights Reserved.

Using Gmail. Created by the Columbia Basin Alliance for Literacy. Margaret Sutherland

FEEDBACK ONLINE PARTICIPANT USER S GUIDE

Module Certification and Testing

TALENT Part 1 page 1 of 1

Registering for the Self Service Website from a Non-City. Computer

Black Box Software Testing (Academic Course - Fall 2001) Cem Kaner, J.D., Ph.D. Florida Institute of Technology

Introducing Computer Programming

Shift Left Testing: are you ready? Live Webinar, Sept 19

How to Set up Your Fundraising Page, Connect with Facebook and Raise funds for WINGS

Palm Beach Masters Instructions for Online Enrollment of Automated Credit Card Payments

Instructions for Manufacturer's Agent New Registration. e-file

VLE Corner User Manual. Important Note for Users!!

How to use your Participant Center for fundraising success! How to: Login

Web-Based Contract Management Services. Global Functions User Guide

Effective Information Management and Governance: Building the Business Case for Taxonomy

Online Order System. User Manual. Website User Manual 1

Ockey.hockeycanada.ca. ehockey Online Clinic Registration English Manual.

Honeywell Discover Online Training Quick Start Guide

CITI ACCESS AND DIRECTIONS FOR EXTRAMURAL PERFORMERS NEW USERS

Watir Recipes. The problem solving guide to Watir. Zhimin Zhan. This book is for sale at

A Proposed Method in Agile Practices to Create Requirements Documentation and Test Cases

NRS Registration for Club Contacts and Team Contacts:

Web Application Expectations

Virtual Terminal. Quick Start Guide. v.01_03/18

WORKSHOP. Writing User Stories

myohsaa Officials User Guide January 17, 2008

CONTENTS INTERNET BANKING GUIDE

How to reset your password when given a PASSCODE from the IT Service Desk. Page 2-8. How to change a Forgotten Password by Yourself.

UK Graduate and Interns & STEM Feedback. UK Associates TAS Process Guide & User Manual

Case Study on Testing of Web-Based Application: Del s Students Information System

Test Automation Practice STC 2012

Service Provider Database. DEPARTMENT OF HEALTH Service Provider Database Occupational Therapists Self-Registration How-To Document

Test Driven Development and Refactoring. CSC 440/540: Software Engineering Slide #1

Agile Engineering. and other stuff I m working on

Up and Running Software The Development Process

Automated Acceptance Testing

Ruby on Rails Welcome. Using the exercise files

Difference Card Mobile

Ecological Waste Management Ltd Privacy Policy

How to Register for the 2016 Walk to End Alzheimer s

Access Expense App Tutorial

How do I merge two accounts? It is now possible to merge the accounts yourself.

Bridges Referral Process Training Guide - Referral Partners

i2i Systems Self-Service Support Portal

Software Engineering I (02161)

TestOptimal. A short introduction...

CSCU9B2 Practical 1: Introduction to HTML 5

Building in Quality: The Beauty of Behavior Driven Development (BDD) Larry Apke - Agile Coach

elocalise Mobile Introduction

User Guide Preface Readme Audience Vocabulary Navigation

HP ALM. Software Version: Tutorial

Iron Workers District Council of Western New York and Vicinity Benefit Funds. iremit Online Remittance Instructions

SIMnet Online Student Registration Guide

AROC Online Services (AOS) User Manual

Smart Bulk SMS & Voice SMS Marketing Script with 2-Way Messaging. Quick-Start Manual

Logging in. Below this is a series of links to the course structure documentation for each unit in the Level 3 Diploma in Castings Technology.

2016 AHA ANNUAL SURVEY WALK-THROUGH THE 2016 AHA ANNUAL SURVEY ONLINE

ONLINE REGISTRATION STEP BY STEP STUDENT GUIDE

WHITEPAPER. Is Single Automation Framework possible for all Application Layers?

HP ALM. Software Version: Tutorial

Transcription:

Functional Test Refactoring in Web Test Automation Zhimin Zhan Agile Test Coach, AgileWay

QLD Health Workers

Queensland Health's bungled new payroll system was not properly tested - QLD Auditor-General Report 29/06/2010 http://www.computerworld.com.au/article/351475/pay_system_properly_tested_report/

In order to complete fix it, it will take a couple of years. - Premier Anna Bligh 20/10/2010 Government to sp $209 million fixing Queensland Health payroll system -2011-1 http://www.brisbanetimes.com.au/queensland/government-to-sp-209-million-fixing-queensland-health-payroll-system-20101123-184v9.html

Why? No regression testing! "Our wonderful CorpTech has done another 'system fix' and that has created all these other problems!!!!" - payroll client service officer, 2011-07-23 The only practical way to manage regression testing is to automate it. - Steve McConnell, software leg http://www.couriermail.com.au/news/queensland/new-pay-joke-on-qld-health-staff/story-e6freoof-1226100066383

Test Automation - Reality Check Automated testing through the GUI is intuitive, seductive, and almost always wrong! - Robert C. Martin, 2009-09-30 UI Test Automation Tools are Snake Oil - Michael Feathers, 2010-01-04 For 95% of all software applications, automating the GUI is a waste of time. - Alan Page, is one of Microsoft's first Test Architects http://blogs.msdn.com/b/alanpa/archive/2008/09/18/gui-schmooey.aspx http://blog.objectmentor.com/articles/2009/09/29/ruining-your-test-automation-strategy http://blog.objectmentor.com/articles/2010/01/04/ui-test-automation-tools-are-snake-oil

IDT Survey 2007 "73% of survey respondents believe Automated Software Testing is beneficial but few automated!" Regression testing phases as most time consuming Why? Lack of Time Lack of Budget Lack of Expertise http://journal.thedacs.com/issue/43/90

Test Automation Camel Hard to maintain Test Refactoring Learning Curve: Steep Long feedback loop Out of Reach: Expensive Continuous Integration Graphic from http://www.freevectordownload.com, Licnese: Creative Commons Attributes 3.0

Create your first test < 2 minutes

Test Framework: RWebSpec/Watir Story ID: Story/TestCase # Comments start with # story [01] User can login do open_browser http://travel.agileway.net text_field(:name,"username").set "agileway" enter_text("password", "test") click_button("sign In") Steps page_text.should contain("login OK!") Assertion # Next Story Test

Record/Playback!= Automation Record/Playback scripts are notoriously costly from a maintenance perspective. - Agile Testing p315 Record/playback testing tools should be clearly labeled as training wheels - Jason Huggins, Creator of Selenium

Assume your web site has 100 web pages, and you recorded/developed 100 automated test cases. Now programmer made two simplest changes on Page 2 and 39. Question: To make these 100 tests pass again, how would you do it? how long will it take?

Maintainable automated test scripts

Natural - Maintainable How do we talk about web sites everyday? login you shall see account summary page on there, click select pay by credit card Enter your credit card details on payment page Record receipt number on confirmation page

Recorded Test Scripts test [02] Book Flight do enter_text("user_session[login]", agileway ) enter_text("user_session[password]", test ) click_button("sign in") select_option("fromport", Brisbane ) select_option("toport", Sydney ) click_button("continue") enter_text("passengerfirstname", Zhimin ) enter_text("passengerlastname", Zhan ) click_button("confirm") page_text.should include( Brisbane to Sydney )

Using Page Objects test [02] Book Flight do HomePage FlightPage PassengerPage ConfirmPage home_page = expect_page Homepage home_page.enter_user agileway home_page.enter_password test flight_page = home_page.click_signin flight_page.select_from Brisbane flight_page.select_to Sydney passenger_page = flight_page.click_next passenger_page.enter_firstname Zhimin passenger_page.enter_lastname Zhan passenger_page.click_next expect_page ConfirmPage assert_text_present( Brisbane to Sydney )

Demo: Update Test Scripts with Page Objects Programmer changed the home page TextField login now called username username What will happen to our automated test cases...

Functional Test Refactoring

Functional Test Refactoring A step by step process to refine test scripts to make it easy to read, concise, and more importantly easy to maintain. DRY Don t Repeat YourSelf Recorded Test Scripts Refactor Maintainable Test Scripts

Test Refactoring Benefits Optimising test scripts systematically easy to maintain easy to read simple fast intelligent Team consensus

Next-Gen functional testing tool Agile Alliance workshop on Next-Generation Functional Testing (Oct 2007), Envision: We are lacking IDE that facilitate things like: refactoring test elements command completion incremental syntax validation keyboard navigation debugging Michael Longin s Agile 2009 Wrap up: IDE s are the next step in automated tools http://www.infoq.com/news/2007/10/next-gen-functional-testing http://devxero.wordpress.com/2009/08/28/agile-2009-wrapup/

TestWise IDE

Next-Gen Test Tool : TestWise

Refactorings

1- Extract Function You have long logically grouped test steps performing a common operation Extract them into a reusable function

Extract Function - Example test case 1 do enter_text("username", "david") enter_text("password", "four") click_button("sign In") test case 2 do enter_text("username", "john") enter_text("password", "five") click_button("sign In") Reusable Function def login(username, password) enter_text("username", username) enter_text("password", password) click_button("sign In") test case 1 do login("david", "four") test case 2 do login("john", "five")

Extract Function - Benefits DRY Concise Reusable Easy to maintain DSL, use own words

Extract Function - Demo

Don t forget to run immediately after refactoring

2 - Move Function to Helper You have use same functions defined in separate test scripts files Move the function to the shared helper

Move to Helper - Example # Test Script 1 def login(username, password) enter_text("username", username) enter_text("password", password) click_button("sign In") test case 1 do login("david", "four") # Test Script file 2 def login(username, password) enter_text("username", username) enter_text("password", password) click_button("sign In") test case 2 do login("john", "five") #... # test_helper.rb def login(username, password) enter_text("username", username) enter_text("password", password) click_button("sign In") # Test Script 1 test case 1 do login("david", "four")... # Test Script 2 test case 2 do login("john", "five") #... In Shared test_helper

Move to Helper - Benefits DRY Concise Auto Complete (with tools support)

Move to Helper - Demo

3 - Move You have same set beginning or ing test steps in multiple test cases Move common test steps into shared sections that run before/after each test case

Move Example test Change password do login_as("agileway") change_password("old", "new") login_as("agileway", new ) logout test Change address do login_as("agileway") change_address("city", "Sydney") verify_address("sydney") logout before(:each) do after(:each) do test Change address do change_password("pass", "new") login_as("agileway", new ) test Change address do change_address("city", "Sydney") verify_address("sydney")

Move - Benefits DRY Concise Focused Test

Move - Demo

4 - Extract Page Class The name of a function does not reveal its purpose Change function name

Extract Page Class - Example test script file test case 1 do enter_text("username", "david") enter_text("password", "test") click_button("sign In") test script file test case 1 do home_page = expect_page Homepage home_page.enter_user david home_page.enter_password test home_page.click_signin In page class: HomePage def enter_user(username) enter_text("username", username) def enter_password(pass) enter_text("password", pass) def click_signin click_button("sign In")

Extract Page Class - Benefits DRY Concise Reusable Easy to maintain DSL, easy to read Auto complete via tool support

Extract Page Class - Demo

5 - Introduce Page Object Want to use a predefined Page class Introduce a page object

Introduce Page Object: Example expect_page HomePage home_page = expect_page HomePage home_page.operation

6 - Rename The name of a function does not reveal its purpose Change function name

Rename : Example In Page Class: HomePage def click_signin click_button("sign In") In Page Class: HomePage def click_login click_button("sign In") test script file test case 1 do home_page = expect_page Homepage home_page.enter_user david home_page.enter_password test home_page.click_signin another test script file All references of this function updated test case 2 do home_page = expect_page Homepage home_page.enter_user david home_page.enter_password test home_page.click_signin test script file test case 1 do home_page = expect_page Homepage home_page.enter_user david home_page.enter_password test home_page.click_login another test script file test case 2 do home_page = expect_page Homepage home_page.enter_user david home_page.enter_password test home_page.click_login

Rename Benefits Keep test scripts readaility Quite Important

Rename - Demo

Test Automation in a Real Project 2 and half years 5 7 Users 250 Test Cases 94 Page Class Running on two machines concurrently 2 Hours 200,000+ test case executions

Thanks Questions? Happy Functional Testing http://testwisely.com