The purpose of regression testing is to ensure that changes made to software, such as adding new features or modifying existing features, do not adversely affect features of the software that should not change. It is not cost-effective to rerun all the tests in a regression suite; a method is needed to reduce the testing effort. Regress is just such a tool which supports test set minimization and test prioritization. It helps testers identify a representative subset of tests which should be re-executed to revalidate modified software.
Regress supports test set minimization to reduce the number of test cases contained in a test set without loss of code coverage. In other words, it minimizes a test set to find a minimal subset in terms of the number of test cases that preserves the code coverage with respect to a certain criterion (block, decision, c-use, p-use or all-uses as explained in Section 3.3, What Does ATAC Do?) of the original test set. Regress also supports test set prioritization by sorting tests in increasing order of additional coverage per cost.
For test set minimization, Regress uses an implicit enumeration algorithm with reductions
to find the optimal subset based on all tests examined. In addition, to determine the exact
minimized subset, Regress also provides options to select a fast but approximate solution
based on greedy heuristics in case the exact solution is not obtained in reasonable time. For
test set prioritization, Regress first selects a test case which gives the maximal coverage
with respect to a given criterion per unit cost. Subsequent tests are selected based on their
additional coverage per unit cost.
The remainder of this chapter is organized as follows: Section 11.2 describes how to conduct test set minimization via a character-based user interface, Section 11.3 describes how to perform test set prioritization via a character-based user interface and Section 11.4 explains how these procedures are executed via a graphical user interface.
11.2 Test set minimization via a character-based user
interface
In this section we explain how test set minimization is done via a character-based user
interface. The same wordcount program as used before is used here. To copy these files,
create a new directory, cd to it, and copy the contents of the directory in which the tutorial
files are installed into the new directory. For the illustrations in this chapter, we will use:
(1) two c files: main.c and wc.c, (2) three data files: input1, input2, and input3, (3) the
Makefile and (4) the tests_regress script. Compile the wordcount program with ATAC.
Refer to Appendix A, Platform Specific Information to determine the correct command to
execute for your setup.
After the compilation, two .atac files (main.atac for main.c and wc.atac for wc.c) and the
executable wordcount(.exe) are created. Note, one .atac file is created for each
instrumented .c file, i.e., the .c files compiled with ATAC.
===== These tests are executed ===== wordcount input1 wordcount -x input1 wordcount < input1 wordcount nosuchfile wordcount -wlc input1 wordcount input1 input2 wordcount "-?" wordcount -l input1 wordcount -w input1 wordcount -l < input1 wordcount -w < input1 wordcount -c < input1 wordcount -l nosuchfile wordcount -lx input1 wordcount input1 nosuchfile wordcount empty wordcount input3 |
prompt:> atac -q main.atac wc.atac wordcount.traceis in Figure 11-2. From this figure, it is obvious that some tests are redundant in terms of coverage. A minimal cost subset of these tests which has the same block, decision and all- uses coverage as the original set can be obtained by executing the command:
prompt:> atac -Mq main.atac wc.atac wordcount.trace
% blocks % decisions % C-Uses % P-Uses test (cumulative) (cumulative) (cumulative) (cumulative) ------------- ------------- ------------- ------------- ------------- 75(38/51) 66(23/35) 49(45/92) 71(22/31) wordcount.9 80(41/51) 74(26/35) 66(61/92) 81(25/31) wordcount.16 84(43/51) 77(27/35) 68(63/92) 84(26/31) wordcount.4 90(46/51) 83(29/35) 72(66/92) 90(28/31) wordcount.3 92(47/51) 89(31/35) 76(70/92) 94(29/31) wordcount.8 92(47/51) 91(32/35) 85(78/92) 97(30/31) wordcount.6 98(50/51) 94(33/35) 87(80/92) 97(30/31) wordcount.14 100(51) 97(34/35) 90(83/92) 97(30/31) wordcount.5 100(51) 97(34/35) 93(86/92) 97(30/31) wordcount.11 100(51) 97(34/35) 96(88/92) 97(30/31) wordcount.12 100(51) 97(34/35) 97(89/92) 97(30/31) wordcount.2 100(51) 97(34/35) 98(90/92) 97(30/31) wordcount.13 100(51) 97(34/35) 99(91/92) 97(30/31) wordcount.15 100(51) 97(34/35) 100(92) 97(30/31) wordcount.10 100(51) 100(35) 100(92) 97(30/31) wordcount.7 100(51) 100(35) 100(92) 100(31) wordcount.17 |
|
11.2.1 Forcing Tests to be in the Minimal Set
There are some tests that you always want to be included in the minimal set regardless of
whether they provide additional cost-effective code coverage, such as tests that detect
previously fixed programming faults. You can force the inclusion of such tests in the
minimal set by giving them a cost of 0 using atactm.
11.2.2 Choosing a Reduced Subset after Minimization
In some cases, a cost effective test set need not be minimal. Suppose you only have two
hours to execute some subset of your regression test set; then you would like to execute the
most effective subset during that time. You may wish to make the cost versus effectiveness
trade-off decision yourself. In this case you can run ATAC minimization with the -K option
to print out a cumulative summary of the cost. For example, a cumulative summary as
shown in Figure 11-4 for tests in Figure 11-1 is generated by entering:
prompt:> atac -MKq main.atac wc.atac wordcount.trace
cost % blocks % decisions % C-Uses % P-Uses test (cum) (cumulative) (cumulative) (cumulative) (cumulative) ------ ------------- ------------- ------------- ------------- ------------- 10 75(38/51) 66(23/35) 49(45/92) 71(22/31) wordcount.9 30 80(41/51) 74(26/35) 66(61/92) 81(25/31) wordcount.16 40 84(43/51) 77(27/35) 68(63/92) 84(26/31) wordcount.4 60 90(46/51) 83(29/35) 72(66/92) 90(28/31) wordcount.3 80 92(47/51) 89(31/35) 76(70/92) 94(29/31) wordcount.8 140 92(47/51) 91(32/35) 85(78/92) 97(30/31) wordcount.6 180 98(50/51) 94(33/35) 87(80/92) 97(30/31) wordcount.14 220 100(51) 97(34/35) 90(83/92) 97(30/31) wordcount.5 270 100(51) 97(34/35) 93(86/92) 97(30/31) wordcount.11 320 100(51) 97(34/35) 96(88/92) 97(30/31) wordcount.12 370 100(51) 97(34/35) 97(89/92) 97(30/31) wordcount.2 420 100(51) 97(34/35) 98(90/92) 97(30/31) wordcount.13 480 100(51) 97(34/35) 99(91/92) 97(30/31) wordcount.15 550 100(51) 97(34/35) 100(92) 97(30/31) wordcount.10 630 100(51) 100(35) 100(92) 97(30/31) wordcount.7 780 100(51) 100(35) 100(92) 100(31) wordcount.17 |
|
prompt:> atac -Mq -mbd main.atac wc.atac wordcount.traceIn this case, test set size is reduced to from 17 to 6, which corresponds to a major size reduction.
% blocks % decisions test (cumulative) (cumulative) ------------- ------------- ------------- 75(38/51) 66(23/35) wordcount.9 86(44/51) 77(27/35) wordcount.3 94(48/51) 83(29/35) wordcount.14 98(50/51) 91(32/35) wordcount.15 100(51) 97(34/35) wordcount.12 100(51) 100(35) wordcount.7 |
|
prompt:> atac -M main.atac wordcount.traceThe output of this appears in Figure 11-6.
prompt:> atac -M -F main -F count main.atac wc.atac wordcount.trace
prompt:> atac -MKq -mb -n "wordcount.?" main.atac wc.atac wordcount.traceThe output generated is in Figure 11-7.
prompt> atac -MKq -mb -x -n "wordcount.?" main.atac wc.atac wordcount.tracecomputes a minimal test set with respect to block coverage for all tests in Figure 11-1 except the first nine. The generated summary report is displayed in Figure 11-8.
cost % blocks test (cum) (cumulative) ------ ------------- ------------- 20 53(27/51) wordcount.16 70 86(44/51) wordcount.11 110 94(48/51) wordcount.14 160 98(50/51) wordcount.13 210 100(51) wordcount.12 |
prompt:> atac -Q main.atac wc.atac wordcount.traceThe corresponding output is in Figure 11-9. Test wordcount.9 is selected as the first test because it gives the maximum coverage with respect to block, decision, c-use and p-use per unit cost. Subsequent tests are selected based on their additional coverage with respect to these four criteria per unit cost. In our case, wordcount.16 is selected after wordcount.9 because it gives the maximal additional block, decision, c-use and p-use coverage per unit cost.
prompt:> atac -MKq -mb main.atac wc.atac wordcount.traceto get the minimal set with respect to the block coverage1. The output generated is shown in Figure 11-10.
cost % blocks test
(cum) (cumulative)
------ ------------- -------------
20 53(27/51) wordcount.3
30 65(33/51) wordcount.4
70 94(48/51) wordcount.5
110 100(51) wordcount.14
11.4 Test set minimization and prioritization via a graphical
user interface
We now repeat test set minimization and prioritization via a graphical user interface using
the same main.atac, wc.atac and wordcount.trace files as those in Section 11.2. Since the
current version of the Toolsuite's graphical interface does not support all the features discussed in Section 11.2 and
Section 11.3, we will only illustrate those that are supported. Invoke the graphical interface of the Toolsuite by typing:
prompt:> xsuds main.atac wc.atac wordcount.traceThen, pull down the ``Tool'' menu and select the ``xregress'' option. Click on the ``TestCases'' button in the top button bar to see the cumulative coverage by test case with respect to the selected coverage criteria. By default, five criteria -- function-entry, block, decision, c-use and p-use -- are selected. The resulting window appears in Figure 11-11 with tests listed in the order of decreasing added coverage per unit cost.
|
|
By default, Regress is in greedy_order which sorts test cases in order of increasing cost per additional coverage. You can switch to optimal_order to do the test set minimization by clicking on the ``Minimize_in'' button in the middle button bar and selecting ``optimal_order''. The updated test cases window is displayed in Figure 11-13. The Test cases frame at the lower-right corner shows ``4 of 17'' indicating that only the first four tests (wordcount.3, wordcount.4, wordcount.5 and wordcount.14) are included in the minimized subset with the same block coverage as the original test set. The same output can be obtained via the character-based interface by entering the following on the command line:
prompt:> atac -M -mb main.atac wc.atac wordcount.trace
|
To quit Regress click on the ``File'' button in the top button bar and select ``exit''.