Java Reference
In-Depth Information
7.8 Regression Testing
It is a common and useful practice to make a new test whenever you find a program
bug. You can use that test to verify that your bug fix really works. Don't throw the
test away; feed it to the next version after that and all subsequent versions. Such a
collection of test cases is called a test suite.
A test suite is a set of tests for repeated testing.
You will be surprised how often a bug that you fixed will reappear in a future version.
This is a phenomenon known as cycling. Sometimes you don't quite understand the
reason for a bug and apply a quick fix that appears to work. Later, you apply a
different quick fix that solves a second problem but makes the first problem appear
again. Of course, it is always best to think through what really causes a bug and fix
the root cause instead of doing a sequence of ȒBand-Aidȓ solutions. If you don't
succeed in doing that, however, you at least want to have an honest appraisal of how
well the program works. By keeping all old test cases around and testing them against
every new version, you get that feedback. The process of testing against a set of past
failures is called regression testing.
Regression testing involves repeating previously run tests to ensure that known
failures of prior versions do not appear in new versions of the software.
How do you organize a suite of tests? An easy technique is to produce multiple tester
classes, such as BankTester1, BankTester2 , and so on.
Another useful approach is to provide a generic tester, and feed it inputs from
multiple files. Consider this tester for the Bank class of Section 7.5 :
ch07/regression/BankTester.java
1 /**
2 This program tests the Bank class.
3 */
4 public class BankTester
5 {
6 public static void main(String[] args)
Search WWH ::




Custom Search