test automation patterns: issues and solutions
TRANSCRIPT
MN PM Tutorial
10/13/2014 1:00:00 PM
"Test Automation Patterns: Issues and
Solutions"
Presented by:
Seretta Gamba, Steria Mummert ISS GmbH
Mark Fewster, Grove Software Testing Ltd.
Brought to you by:
340 Corporate Way, Suite 300, Orange Park, FL 32073
888-268-8770 ∙ 904-278-0524 ∙ [email protected] ∙ www.sqe.com
Seretta Gamba
Steria Mummert ISS GmbH Seretta Gamba has more than thirty years’ experience in software development and testing. As test manager at Steria Mummert ISS GmbH, Seretta was charged with improving their test automation process. After studying other strategies, she developed command-driven testing and a supporting framework. Seretta presented an enhancement to the framework that enabled the test automation team to “harvest” test case information by supporting manual testing. A description of this experience became a chapter in Experiences of Test Automation by Dorothy Graham and Mark Fewster.
Mark Fewster
Grove Software Testing Ltd. Mark Fewster has more than thirty years of experience in software testing ranging from test management to test techniques and test automation. For the past two decades, Mark has provided consultancy and training in software testing, published papers, and co-authoredSoftware Test Automation and Experiences of Test Automation with Dorothy Graham. A popular speaker at conferences worldwide, Mark has won the Mercury BTO Innovation in Quality Award. He is currently helping ISTQB define the expert level certification for test automation. Speaker Presentations
11/09/2014
1
Patterns in Test Automation: Issues and Solutions
Prepared and presented by
Seretta Gamba
[email protected]@yahoo.com
© Seretta Gamba, Dorothy Graham, Mark Fewster 2014
Mark Fewster
[email protected] Software Testing
Tutorial objectives
� help you recognize test automation issues
� explore ways of solving automation issues
using patterns
� work on example scenarios*
*using Test Automation Patterns wiki on your laptop or internet-enabled device
�NOTE: system level automation, not unit level
�NOTE: test automation patterns, not test patterns
11/09/2014
2
Issues (problems)
� what problems affect you in test
automation?
� what causes the most trouble?
� what takes longer than it should?
� what is holding you back in your
automation?
� what are you struggling with?
� what would you most like to improve?
Background
Issues and Patterns
Two case studies
Exercise
More about some patterns
Conclusion
Agenda
11/09/2014
3
Origin of patterns in software
� 1970s: architect Christopher Alexander describes
patterns for buildings (e.g. light from 2 walls)
� 1987: Kent Beck & Ward Cunningham
experimented & presented at OOPSLA
� 1994: “Gang of Four” wrote a book applying pattern
principles to software design
� “Design Patterns: elements of reusable object-oriented
software”, Erich Gamma, Richard Helm, Ralph Johnson,
John Vlissides
� now widely accepted in software development
community
Origin of Test Automation Patterns
� Experiences book published 2012
� Seretta contributed Ch 21� Automation through the back door,
by supporting manual testing
� she is a developer, used tousing patterns
� when she read the other chapters, she thought: “Patterns! Patterns!”
� she wrote up test automation patterns as a book & asked Dot to join her
� Word didn’t work very well, so we made a wiki
11/09/2014
4
Test automation patterns wiki
� purpose: share information, ideas and experiences about test automation, using issues and patterns
� mind-maps summarize issues and patterns (not clickable as links)
� issues and patterns are classified into sub-sections (e.g. management, process, etc.)
� wiki started 28 January 2013
About the patterns in the wiki
� the wiki has a limited set of patterns
� patterns use other patterns
� we are focusing on system-level automation
rather than unit test automation
� See Gerard Meszaros’ book “xUnit Test
Patterns: Refactoring test code” for unit test
patterns
� a “work in progress”
� a new way of presenting known information
11/09/2014
5
Background
Issues and Patterns
Two case studies
Exercise
More about some patterns
Conclusion
Agenda
Test Automation Issues
� An Issue is a problem that testers and/or
test automators encounter when trying to
do test automation
� They are things that take longer than they
should, that hold you back in what you
want to automate, or that are just too
much trouble
11/09/2014
6
Test Automation Issues (~75)
� Process Issues: problems that occur when the
test automation process has not yet reached the
necessary maturity
� Management Issues: problems that occur when
management has not given the necessary support
(budget, resources, team)
� Design Issues: problems that occur when an
efficient testware architecture and maintainability
are not built in from the very beginning
� Execution Issues: problems that occur when the
automated tests are run (unpredictable results etc)
Test Automation Patterns
� General reusable solution to a commonly
occurring problem within a given context
� a way of solving an issue or problem in test
automation that has worked in practice for many
people
� a pattern is not prescriptive or a set of steps, but
rather ideas to consider to see if they would
apply in your situation or context
Pattern ���� expert knowledge proven
by repeated experience
11/09/2014
7
Test Automation Patterns (~75)
� Process Patterns: how the test automation
process should be set up or how it can be
improved
� Management Patterns: how to manage test
automation both as an autonomous project or
integrated in the development process
� Design Patterns: how to design the test
automation testware so that it will be efficient and
easy to maintain
� Execution Patterns: how to take care that test
execution is easy and reliable
� General issues are the issues that one feels when
test automation is not going as expected, but one
cannot really pinpoint a specific problem, because
usually more than one is causing the pain
� General issues contain other more specific issues
General Issues
11/09/2014
8
1. Select the general issue that best describes the
most pressing problem in your test automation.
2. Examine what kind of issues can cause it (probably
more than one).
3. Select the one that you deem most pressing.
4. Repeat steps 2. and 3. until you reach the specific
issue that needs to be solved first. It will suggest
the patterns needed to solve it.
5. Select the pattern(s) that best fit your context and
apply it/them.
6. If you still have problems, start again from step 1.
How to use general issues
� You don‘t have to study all the issues
and patterns (50+70)
� The issues lead you to the causes of
your problems
� You can focus on the most effective
patterns
� You can repeat the process as often as
you want
Why use general issues
11/09/2014
9
� One or two participants explain their
most pressing issue
� Using the General issues we will find
what patterns are most appropriate to
solve them
General Issues: Example
Background
Issues and Patterns
Two case studies
Exercise
More about some patterns
Conclusion
Agenda
11/09/2014
10
Seretta’s story
� company background
� Steria-Mummert-ISS, Hamburg / Germany
� Standard Software for insurances
� my background
� developer
� test manager
� 2001, wanted to start automation
� NO PREVIOUS AUTOMATION
NO PREVIOUS TEST AUTOMATION
Resolving Patterns:
1. SET CLEAR GOALS
2. MANAGEMENT SUPPORT
3. DEDICATED RESOURCES
4. RIGHT TOOLS
5. AUTOMATION ROLES
6. PLAN SUPPORT ACTIVITIES
7. MAINTAINABLE TESTWARE
8. AUTOMATE WHAT’S NEEDED
9. TAKE SMALL STEPS
10.UNATTENDED TEST EXECUTION
automate regression
tests for the
registration product
We chose an older
tool that could drive
our application reliably
Done
Done
Done
I knew how to write
good code for the
automation
11/09/2014
11
MAINTAINABLE TESTWARE
� Summary: Design testware so it doesn’t have to be updated for every little change in the Software Under Test (SUT)
� Description:
� Identify the most costly and/or most frequent changes
� Design testware to cope best with those changes
� Implementation
� If objects are frequently renamed use OBJECT MAP or devise a translation table for names
� GOOD DEVELOPMENT PROCESS and GOOD PROGRAMMING PRACTICES
� DOMAIN-DRIVEN TESTING using Keywords
Command-driven testing
� developed a keyword-type test architecture
� minimize scripts that interface directly to the tool
� TOOL INDEPENDENCE
� organized into a Driver-part and a Data-part
� DATA-DRIVEN TESTING
� developed ISS Test Station to make it all work
� TEST AUTOMATION FRAMEWORK
� keywords as simple commands
� e.g. “INPUT”, “SELECT”
� KEYWORD-DRIVEN TESTING
11/09/2014
12
Command script example
Success
� the automation gave us good benefits:
� we had a good architecture and framework
� easy to add new automated tests
� company-wide automation standards
� automated everything we had planned
� expected our ratio of automated to manual
tests to continue to grow
11/09/2014
13
What happened next: Stagnation
� marketing success = automation problem
� increase in business, new features
� developers and testers needed on business-
critical tasks, taken off automation
� leading to new issues:
� INADEQUATE SUPPORT
� INADEQUATE
COMMUNICATION
�NO INFO ON CHANGES
� no time for automation, which
would have given them more
time!
NO PREVIOUS TEST AUTOMATION
Patterns missed:
1. SET CLEAR GOALS
2. MANAGEMENT SUPPORT
3. DEDICATED RESOURCES
4. RIGHT TOOLS
5. AUTOMATION ROLES
6. PLAN SUPPORT ACTIVITIES
7. MAINTAINABLE TESTWARE
8. AUTOMATE WHAT’S NEEDED
9. TAKE SMALL STEPS
10.UNATTENDED TEST EXECUTION
I was doing the
automation in
my “spare time”
I was automator,
tester, developer
and project leader
at first I didn’t
need support,
didn’t think about
this
Initiated by
management,
but not enough
11/09/2014
14
MANAGEMENT SUPPORT
Implementation
Build a convincing TEST AUTOMATION BUSINESS
CASE. Test automation can be quite expensive and
requires, especially at the beginning, a lot of effort.
No business case �
� No real commitment from management to continue
to support test automation,
� Just as for testing in general, test automation
doesn’t come first!
Management initiation of the automation was good,
but it wasn’t enough – needs ongoing support
ImplementationA good way to convince management is to DO A PILOT. In this way they can actually “touch” the advantages of test automation and it will be much easier to win them over.
�SET CLEAR GOALS
�RIGHT TOOLS
�AUTOMATION ROLES
�TAKE SMALL STEPS
�Take time for debriefing when you are through and don't forget to LEARN FROM MISTAKES
I didn’t even notice
that it was missing!
MANAGEMENT SUPPORT
11/09/2014
15
Other Issues
� INADEQUATE TEAM
I could not select the team and had to manage
with colleagues who were not needed for
development!
� AUTOMATION ROLES
� FULL TIME JOB
If you have a pattern, that at least confronts you
with the problem from the beginning. You cannot
say afterwards that you didn’t think about it!.
Case study conclusion
� we unknowingly applied some patterns
�enabled us to achieve success
� we didn’t think about other patterns
�they caused us serious problems later on
� many other people have similar experiences
� some succeed, some don’t
� the test automation patterns can help you on the road to success
11/09/2014
16
Mark’s story
� company background
� electronic design automation systems vendor
� 100 software engineers, 10 manual testers
� growth over 4 years:� 80 to 120 programs
� 2 to 9 platforms
� manual test effort per release nearing 2 years
� my background
� developer to development manager� responsible for reusable software and in-house
tools
What the VP wants
� Managing Director (VP)declared:
� which kicked off the test automation project
� and gave us our first two issues:
UNREALISTIC EXPECTATIONS
NO PREVIOUS TEST AUTOMATION
� but we didn’t realise it at first
“I want 100%
automated testing”
11/09/2014
17
UNREALISTIC EXPECTATIONS
Resolving Patterns:
1. DO A PILOT
2. SHARE INFORMATION
3. SET CLEAR GOALS
4. TAKE SMALL STEPS
This we did,
phew!
We published results
from the pilot, but should
have done more
No, not this. After
the pilot, it was
one giant leap S
We had the
100% target!
NO PREVIOUS TEST AUTOMATION
Resolving Patterns:
1. SET CLEAR GOALS
2. MANAGEMENT SUPPORT
3. DEDICATED RESOURCES
4. RIGHT TOOLS
5. AUTOMATION ROLES
6. PLAN SUPPORT ACTIVITIES
7. MAINTAINABLE TESTWARE
8. AUTOMATE WHAT’S NEEDED
9. TAKE SMALL STEPS
10.UNATTENDED TEST EXECUTION
Not really. 100% is clear
but not realistic.
We won this early on
but didn’t sustain it.
Yes!
Over time, as we learnt
what was needed.
Yes, clear distinction.
No.
Yes.
Yes.
No.
Yes.
11/09/2014
18
The pilot
� automate integration testing
� typically 10 weeks of manual test effort
� develop tools required
� quick and dirty slightly blemished at first
� short cuts at the cost of usability
� improved tools later
� usability became much more important
Pilot issues
� INADEQUATE TOOLS
� early on tools being developed� but requirements unclear!
� useful patterns:� TEST AUTOMATION FRAMEWORK
� LEARN FROM MISTAKES
� SELL THE BENEFITS
� TESTABLE SOFTWARE
� HARD TO AUTOMATE
� useful patterns:� TESTABLE SOFTWARE
� THINK OUT-OF-THE-BOX
� KEEP IT SIMPLE
11/09/2014
19
Automating system testing
� involved more people
� on team and people outside team
� issues:
� INADEQUATE COMMUNICATION
�DATA CREEP
�NO INFO ON CHANGES
�GIANT SCRIPTS
� INSUFFICENT FAILURE ANALYSIS
Automation project results
� test effort per platform cut by 80%
� consistency of regression testing
� deskilled test running
� bug fixes fully regression tested
� improved time to market
� improved cross-platform quality
11/09/2014
20
Background
Issues and Patterns
Two case studies
Exercise
More about some patterns
Conclusion
Agenda
Exercise
� 5 scenarios
� choose 1 to start, other(s) afterwards
� explore the wiki with a partner
� testautomationpatterns.org
� using the diagnostics, identify the problems for the person in the scenario
� what issue(s)?
� what pattern(s) would be most appropriate in this context?
� solution ideas will be given
11/09/2014
21
Background
Issues and Patterns
Two case studies
Exercise
More about some patterns
Conclusion
Agenda
More about implementing patterns
� using a few examples
� CLEAR GOALS
� ABSTRACTION LEVELS
� DATA-DRIVEN vs KEYWORD-DRIVEN
� other patterns (chosen by you)
� (time permitting!)
11/09/2014
22
Pattern: SET CLEAR GOALS
Define the automation goals / objectives from the very
beginning in a way that is clear and understandable to
all.Context
This pattern is always applicable, although the goals
may be different at different stages.
� when you first consider test automation
� when an automation initiative is getting started
� when your automation is going well
� when you want to revitalize a stalled automation
effort.If you don‘t know what your goals are, how do you
know that you are going in the right direction?
Description
� automation objectives defined clearly up front
� no disappointment later.
� Inform your managers about what is feasible
and what is not.
Pattern: SET CLEAR GOALS
Goals should be measurable so that you can tell if
you have achieved them or not
11/09/2014
23
Implementation examples
� Selected regression tests should run x-times faster
and y-times more often.
� Tests too complex to perform manually are to be
automated. Define exactly which ones.
Not good goals
� Confuse the goals for automation with goals for
testing.
� Automate all manual tests
Pattern: SET CLEAR GOALS
Potential problems
Be sure to remind management that it may not be
possible or advisable to automate every test case.
Good objectives/goals for automation?
� run regression tests evenings and weekends
� increase test coverage
� run tests tedious and error-prone if run manually
� gain confidence in the system
� reduce the number of defects found by users
only if they are worthwhile tests!
can be a good one but depends what is meant by “test” coverage
good automation objective
an objective for testing, but automated regression tests help
achieve it
good objective for testing, maybe not a good
objective for automation!
11/09/2014
24
Same tests
automated
edit tests
(maintenance) set-up execute
analyse
failures clear-up
Manual
testing
More mature
automation
Reduce test execution time
Automate x% of the manual tests?
manual
tests automated
tests
tests not
worth
automatingexploratory
test
automation
manual tests
automated
(% manual)
tests (&
verification) not
possible to do
manually
tests not
automated
yet
11/09/2014
25
Tests usually automated?
regression tests exploratory testing
likelihood of
finding bugs
most often
automated
automation objective – find lots of bugs?
No! - not for regression test automation
Find more bugs?
� tests find bugs, not automation
� automation is a mechanism for running tests
� the bug-finding ability of a test is not affected
by the manner in which it is executed
� this can be a dangerous objective
� especially for regression automation!
Automated tests Manual Scripted Exploratory Fix Verification
9.3% 24.0% 58.2% 8.4%
Experiences of Test Automation, Ch 27, p 503, Ed Allen & Brian Newman
11/09/2014
26
Build testware that has one or more
abstraction layers (or levels of separation)
Context
Apply this pattern for long-lasting and maintainable
automation
- not necessary for disposable scripts
If you don’t take this into consideration in the design
of your testware architecture, you are likely to have
HIGH MAINTENANCE COSTS and will not achieve
the success you could have had.
Pattern: ABSTRACTION LEVELS
Pattern: ABSTRACTION LEVELS
Description
� separate your testware from the tool-specific
scripting language as much as possible
� make your scripts modular and independent
(following GOOD PROGRAMMING
PRACTICES)
� build an interface so that testers and others
can easily write and run automated tests
11/09/2014
27
Pattern: ABSTRACTION LEVELS
Implementation examples
� DATA-DRIVEN TESTING
� KEYWORD-DRIVEN TESTING
� DOMAIN-DRIVEN TESTING
� MODEL-BASED TESTING
Potential problems
It takes time and effort to build a good TESTWARE
ARCHITECTURE that uses levels of abstraction
Abstraction levels
abstraction here:
easier to write
automated tests
� widely used
abstraction here:
easier to maintain,
and change tools
� long life
test
wa
re a
rch
ite
ctu
re
Testers
Test Execution Tool
runs scripts
High Level
Keywords
Structured
Scripts
structured
testware
Test
Automator(s)
write tests (in DSTL)
11/09/2014
28
re-usable modules / script library
Progression of aut. implementation
low-level
instructions
structured
code
data
driven
keyword/
domain
driven
manual test
scripts
input
data
test
definitions
get quote - motor, age, S
create policy – motor, age, S
Technical
Test
Analyst
Test
Analyst
easier maintenance
Data-driven example
Name Earn1 Earn2 Earn3
Pooh 100 150 125
Piglet 75 90 80
Roo 120 110 65
Sub RunTests()
For each Row in file
Call OpenApplication(“TaxCalculator”)
Open TaxCalcData.csv
Read Name
Read Earn1
Read Earn2
Read Earn3
Call CalculateTax(Name, Earn1, _
Earn2, Earn3)
Call SaveAsAndClose(Test & “ Results”)
Next Row
End Sub
11/09/2014
29
Keyword-driven example
CalculateTax Pooh, 100, 150, 125
CalculateTax Piglet, 75, 90, 80
CalculateTax Roo, 120, 110, 65
Keyword file (option 1)
CalculateTax
Pooh, 100, 150, 125
Piglet, 75, 90, 80
Roo, 120, 110, 65
Keyword file (option 2)
Keyword file (Robot Framework)Test Case Action Arg1 Arg2 Arg3 Arg4
Check Tax Calculate Tax Pooh 100 150 125
Calculate Tax Piglet 75 90 80
Calculate Tax Roo 120 110 65
CalculateTax Datafile.txt
Keyword file (option 3)
Name Earn1 Earn2 Earn3
Pooh 100 150 125
Piglet 75 90 80
Roo 120 110 65
Datafile.txt
Background
Issues and Patterns
Two case studies
Exercise
More about some patterns
Conclusion
Agenda
11/09/2014
30
Feedback/discussion
� discussion of issues, patterns, wiki
� did you use the General Issues?
�were they helpful?
� what issues & patterns did you look at?
� what was most useful for you?
� what else would be helpful?
� any problems finding what you wanted?
� how will you apply the patterns to your own automation?
Using the wiki
� this is a new resource that will grow
� the more you add, the more valuable it will be
� please add your experiences of patterns, tips, problems, solutions
� feel free to email us with your ideas� we can put your text on the wiki
� or give you access to edit the wiki yourself
� we welcome feedback on the wiki ☺
11/09/2014
31
Finally
� Thank you for coming today!
� Any questions now?
� Contact us afterwards:
� All the best with your test automation!