Pitfalls and Strategies in Automated Testing: Problems With Maintainability
Pitfalls and Strategies in Automated Testing: Problems With Maintainability
Editor: James Bach, ST Labs, Sterling Plaza, Third Floor, 3535 128th Ave. SE, Bellevue, WA 98006; [email protected]; http://www.stlabs.com
Software
Realities
Pitfalls and
• Automating only easy-to-run tests.
Early in testing, a program might be
unable to pass complex test cases.
Later, though, simple automated
Strategies in
tests are weak in comparison to the
increasingly harsh testing done by a
skilled manual tester.
Automated
Problems with maintainability
Maintenance requirements don’t go
away just because your friendly auto-
mated tool vendor forgot to mention
Testing
them. Two recurring issues focused our
discussion at the February LAWST:
114 Computer
.
They design and code each test case inde- • understand the requirements, ify the title, column 2 the title typeface,
pendently. Different scripts often repeat • adopt an architecture that helps us column 3 the type size, and so on. A test
exact sequences of commands. This efficiently develop, integrate, and case specifies a combination of values of
approach is as fragile as capture/replay. maintain features and data, the many parameters. Create the matrix
• adopt and live with rules (stan- using a spreadsheet and execute test
STRATEGIES dards) shared by all developers, and cases using a script that reads one row
Automated regression tests can be very • be disciplined. (test case) at a time and runs a series of
effective. Here are some suggestions for miniature scripts, one per column, to set
developing an automated regression test Of all people, testers must realize how the value of each parameter.
strategy that works. important it is to follow a disciplined Suppose the type size specification
approach to software development. moves to a different dialog. With a test
Reset management expectations Without it, we should be prepared to fail matrix you’ll only have to change a few
Despite the belief that test automation as miserably as so many of the applica- lines of code, in the one miniature script
yields rapid payback, every LAWST par- tions we have tested. that handles the size. You will only have
ticipant agreed: Most benefits of GUI- to change these lines once; this change will
level regression automation in release N Data-driven architecture carry over to every test case in the spread-
will not be realized until the development Imagine testing a program that lets a sheet. This separation of code from data
of release N + 1. However, it is possible user create and print tables, manipulat- is tremendously efficient compared to
to realize benefits in release N, such as: ing, among other things modifying the script for each test case.
There are several other ways to set up
• There’s a big payoff in automating a • the face, size, and orientation (hor- a data-driven approach. For example,
suite of acceptance-into-testing izontal or vertical) of the table title; Brett Pettichord fills his spreadsheet with
(“smoke”) tests. You might run • the position of the title relative to lists of commands (“Success with Test
these 50 or 100 times during devel- the table (above, below, or beside); Automation,” Proc. 9th Int’l Software
opment of release N, dwarfing the • the use of graphics (of any size, Quality Week, 1996). Other testers use
cost of developing and maintaining either bitmap or vector) and their sequences of simple test cases or of
the tests. position relative to the table title; machine states.
• You can save time, reduce human • the thickness of the line used as the Another way to drive testing with data
error, and obtain good tracking by table’s bounding box; uses previously created documents.
automating configuration and com- • the number and sizes of rows and Imagine testing a word processor by feed-
patibility tests that you run against columns; ing it a thousand documents. For each
many devices or environments. • the font, face, size of the text in each document, the script makes the program
table cell; load the document and perform a sequence
Take advantage of opportunities for • the use of graphics in each cell; and of simple actions (such as printing).
near-term payback from automation, but • the paper size (letter, legal, A4) and A well-designed data-driven approach
be cautious when looking for short-term orientation of the printout (land- can make it easier for nonprogramming
gains. Cost-justify the automation of scape or portrait). test planners to specify their test cases,
additional test cases. because they can simply write them into
For longer term gains, develop scaf- These parameters are related because the matrix. It can also provide a set of
folding in release N to improve testing they operate on the same page at the tables that concisely show what test cases
breadth and efficiency in release N+1. same time. If the rows are too big, there’s are being run by the automation tool.
no room for graphics. If too many type-
Test automation is faces are used, the program might run Framework-based architecture
software development out of memory. This example cries out A framework isolates the application
Automation of software testing is just for testing the variables in combination, under test from test scripts by providing
like all of the other automation efforts but there are millions of combinations. a set of functions in a shared function
that software developers engage in— Imagine writing 100 scripts to test just library. Test script writers treat these
except that this time, the testers are writ- 100 potential combinations. If one ele- functions as commands of their test
ing the automation code. It is code, even ment of the interface should change—if tool’s programming language.
if the programming language is funky. type size specification moves from one For example, a framework might
Every test case is a really a feature. And dialog box to another—you might have include the function openfile(p),
every aspect of the underlying applica- to revise each script. which opens file p. It might operate by
tion (the one under test) is data. Now imagine working from a test pulling down the file menu, selecting the
As we’ve learned on so many other matrix, in which each row specifies a test Open command, copying the file name
software development projects, develop- case and each column a parameter set- to the file name field, and selecting the
ers must ting. For example, column 1 might spec- OK button to execute the operation. The
116 Computer