COST AND PRACTICAL CONSIDERATIONS

Một phần của tài liệu introduction to combinatorial testing (Trang 180 - 185)

An important cost advantage introduced by coverage measurement is the ability to use existing test sets, identify particular combinations that may be missing, and supplement existing tests. In some cases, as in the example of Figure 7.7, it may be discovered that the existing test set is already strong with respect to a particular strength t (in this case two-way), and tests for t + 1 generated. The trade-off in cost of applying coverage measurement is the need to map existing tests into discrete values that can be analyzed by the coverage measurement tools (see Appendix C). For example, if the test set includes a field with various dollar amounts, it may be necessary to establish equivalence classes such as 0, 1,. . .,1000, >1000, and so on.

Cov >= 0.00 = 45/45 = 1.000 Cov >= 0.05 = 45/45 = 1.000 Cov >= 0.10 = 45/45 = 1.000 Cov >= 0.15 = 45/45 = 1.000 Cov >= 0.20 = 45/45 = 1.000 Cov >= 0.25 = 45/45 = 1.000 Cov >= 0.30 = 0/45 = 0.000 Cov >= 0.35 = 0/45 = 0.000 Cov >= 0.40 = 0/45 = 0.000 Cov >= 0.45 = 0/45 = 0.000 Cov >= 0.50 = 0/45 = 0.000 Cov >= 0.55 = 0/45 = 0.000 Cov >= 0.60 = 0/45 = 0.000 Cov >= 0.65 = 0/45 = 0.000 Cov >= 0.70 = 0/45 = 0.000 Cov >= 0.75 = 0/45 = 0.000 Cov >= 0.80 = 0/45 = 0.000 Cov >= 0.85 = 0/45 = 0.000 Cov >= 0.90 = 0/45 = 0.000 Cov >= 0.95 = 0/45 = 0.000 Cov >= 1.00 = 0/45 = 0.000

2-way 1

0.9 0.8 0.7 0.6 0.5

Coverage 0.4

0.3 0.2 0.1

00.00

0.05 0.15 0.25 0.35 0.45 0.55 Combinations

0.65 0.75 0.85 0.95 0.10 0.20 0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.00

Total 2-way = 0.250 Coverage for file

1test.csv

FIGURE 7.9 Coverage for one test, 10 binary variables.

www.Ebook777.com

These concepts can be used to analyze various testing strategies by measuring the combinatorial coverage they provide.

All-values: Consider the t-way coverage from one of the most basic test criteria, all-values, also called “each-choice” [2]. This strategy requires that every parameter value be covered at least once. If all n parameters have the same number of values, v, then only v tests are needed to cover all. Test 1 has all parameters set to v1, Test 2 to v2, and so on. If parameters have dif- ferent numbers of values, where parameters p1,. . .,pn have vi values each, the number of tests required is at least Maxi=1,n vi.

Example: If there are three values, 0, 1, and 2, for five parameters, then 0,0,0,0,0; 1,1,1,1,1; and 2,2,2,2,2 will test all values once. Since each test covers 1/vt variable-value configurations, and no combination appears in more than one test, with v values per parameter, we have

Mt(all values- )≥ νv1t = v1t

1

So, if all values are covered at least once, for all-values, minimum cover- age M ≥ 1/vt−1. This relationship can be seen in Figure 7.10, which shows cov- erage for two tests with binary variables; two-way minimum coverage = 0.5, and three-way and four-way coverage are 0.25 and 0.125, respectively.

Base choice: Base-choice testing [3] requires that every parameter value be covered at least once and in a test in which all the other values are

0.000.05 0.15 0.25 0.35 0.45 0.55 Combinations

0.65 0.75 0.85 0.95 0.10 0.20 0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.00 1

0.9 0.8 0.7 0.6 0.5

Coverage 0.4

0.3 0.2 0.1

0 2-way

3-way 4-way

Cov >= 0.00 = 210/210 = 1.000 Cov >= 0.05 = 210/210 = 1.000 Cov >= 0.10 = 210/210 = 1.000 Cov >= 0.15 = 0/210 = 0.000 Cov >= 0.20 = 0/210 = 0.000 Cov >= 0.25 = 0/210 = 0.000 Cov >= 0.30 = 0/210 = 0.000 Cov >= 0.35 = 0/210 = 0.000 Cov >= 0.40 = 0/210 = 0.000 Cov >= 0.45 = 0/210 = 0.000 Cov >= 0.50 = 0/210 = 0.000 Cov >= 0.55 = 0/210 = 0.000 Cov >= 0.60 = 0/210 = 0.000 Cov >= 0.65 = 0/210 = 0.000 Cov >= 0.70 = 0/210 = 0.000 Cov >= 0.75 = 0/210 = 0.000 Cov >= 0.80 = 0/210 = 0.000 Cov >= 0.85 = 0/210 = 0.000 Cov >= 0.90 = 0/210 = 0.000 Cov >= 0.95 = 0/210 = 0.000 Cov >= 1.00 = 0/210 = 0.000

Total 4-way = 0.125 Coverage for file

2vals.csv

FIGURE 7.10 (See color insert.) t-Way coverage for two tests with binary values.

158    ◾   Introduction to Combinatorial Testing

held constant. Each parameter has one or more values designated as base choices. The base choices can be arbitrary, but can also be selected as

“more important” values, for example, default values, or values that are used most often in operation. If parameters have different numbers of val- ues, where parameters p1 , . . . , pn have vi values each, the number of tests required is at least 1 +Σ i=1,n (vi− 1), or where all n parameters have the same number of values v, the number of tests is 1 + n(v − 1). An example is shown in Figure 7.11, with four binary parameters.

The base choice strategy can be highly effective, despite its simplicity.

In one study of five programs seeded with 128 faults [91,92], it was found that although the Base Choice strategy requires fewer test cases than some other approaches, it found as many faults [76]. In that study, AETG [61] was used to generate two-way (pairwise) test arrays. We can use combinatorial coverage measurement to help understand this finding. For this example of analyzing base choice, we will consider n parameters with two values each. First, note that the base choice test covers C(n, t) combinations, so for pairwise testing, this is C(n, 2) = n(n − 1)/2. Changing a single value of the base test to something else will cover n − 1 new pairs. (In our example, ab, ac, and ad have new values in test 2, while bc, cd are is unchanged.) This must be done for each parameter, so we will have the original base choice test combinations plus n(n − 1) additional combinations. The total number of two-way combinations is C(n, 2) × 22, so for n binary parameters:

M n n n n

n n

t( ) ( ) / ( )

( , ) ( ,

two way binary base choice- = − + −

=

1 2 1

2 2 2

C 2

C )) ( , ) ( , )

+2 2 = 2 2C2 3 4 C

n

n /

This can be seen in the graph in Figure 7.12 of coverage measure- ment for the test suite in Figure 7.11. Note that the 75% coverage level is independent of n. For v > 2, the analysis is a little more complicated. The

FIGURE 7.11 Base choice test suite for a 24 configuration, where test 1 is base choice values.

base choice test covers C(n, 2), and each new test covers n − 1 new com- binations, but we need v − 1 additional tests beyond the base choice for v values. So, the proportion of two-way combinations covered by the base choice strategy in general is

M n v n

n v v

v

t( ) ( , ) ( ) ( , )

( , ) ( )

base choice = + −

= + −

C C

C

2 2 1 2

2 1 2 1

2 2

For example, with v = 3 values per parameter, we still cover 55.6% of combinations, and with v = 4, coverage is 43.75%. This analysis helps explain why the base choice strategy compares favorably with pairwise testing.

This equation can be generalized to higher interaction strengths. The base choice test covers C(n, t) combinations, and each new test covers C(n − 1, t − 1) new combinations, since the parameter value being varied can be combined with t − 1 other parameters for each t-way combination.

Base choice requires n(v − 1) additional tests beyond the initial one, so for any n, t with nt

M base choicet t

n t n v n t

n t v n t t

( ) ( , ) ( ) ( , )

( , ) ( , ) (

= + − − −

= +

C C

C C

1 1 1

vv n t

n t v t v

v

t t

−1) ( , ) = +1 −1

( , ) C ( )

C

0.000.05 0.15 0.25 0.35 0.45 0.55

Combinations 0.65 0.75 0.85 0.95 0.10 0.20 0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.00 1

0.9 0.8 0.7 0.6 0.5

Coverage 0.4

0.3 0.2 0.1

0 2-way

3-way 4-way

Cov >= 0.00 = 210/210 = 1.000 Cov >= 0.05 = 210/210 = 1.000 Cov >= 0.10 = 210/210 = 1.000 Cov >= 0.15 = 0/210 = 0.000 Cov >= 0.20 = 0/210 = 0.000 Cov >= 0.25 = 0/210 = 0.000 Cov >= 0.30 = 0/210 = 0.000 Cov >= 0.35 = 0/210 = 0.000 Cov >= 0.40 = 0/210 = 0.000 Cov >= 0.45 = 0/210 = 0.000 Cov >= 0.50 = 0/210 = 0.000 Cov >= 0.55 = 0/210 = 0.000 Cov >= 0.60 = 0/210 = 0.000 Cov >= 0.65 = 0/210 = 0.000 Cov >= 0.70 = 0/210 = 0.000 Cov >= 0.75 = 0/210 = 0.000 Cov >= 0.80 = 0/210 = 0.000 Cov >= 0.85 = 0/210 = 0.000 Cov >= 0.90 = 0/210 = 0.000 Cov >= 0.95 = 0/210 = 0.000 Cov >= 1.00 = 0/210 = 0.000

Total 4-way = 0.125 Coverage for file

2vals.csv

FIGURE 7.12 Graph of two-way coverage for test set in Figure 7.11.

160    ◾   Introduction to Combinatorial Testing

7.5 ANALYSIS OF (t + 1)-WAY COVERAGE

A t-way covering array by definition provides 100% coverage at strength t, but it also covers some (t + 1)-way combinations (assuming nt + 1).

Using the concepts introduced previously, we can investigate minimal coverage levels for (t + 1)-way combinations in covering arrays. Given a t-way covering array, for any set of t + 1 parameters, we know that any combination of t parameters is fully covered in some set of tests. Joining any other parameter with any combination of t parameters in the tests will give a (t + 1)-way combination, which has v t+1 possible settings. For any set of tests covering all t-way combinations, the proportion of (t + 1)-way combinations covered is thus vt/vt+1, so if we designate (t + 1)-way variable- value configuration coverage as St+1, then

St+1 ≥ v1 for any -way covering array witht n t≥ +1 (7.3) Note that variable-value configuration coverage is not the same as simple t-way coverage, which gives the proportion of t-way configurations that are 100% covered. Clearly, no set of (t + 1)-way combinations will be fully covered with a t-way covering array, if N < vt+1, where N = number of tests. For most levels of t and v encountered in practical testing, this condition will hold. For example, if v = 3, then a two-way covering array with <33 = 27 tests can be computed [71] for any test problem with <60 parameters. So, the proportion of combinations with full variable-value coverage, designated Φ, will be zero for three-way coverage for this exam- ple. And, in general, designating (t + 1)-way full variable-value configura- tion coverage as Φt+1, if N < vt+1, then Φt+1 = 0, for any t-way covering array with nt + 1.

As an additional illustration, we show that expression (7.3) can also be reached by noting that with a t-way covering array, unique (t + 1)-way combinations can be identified as follows: traversing the covering array, for the first appearance of each t-way combination, appends each of the nt parameters not contained in the t-way combination to create a (t + 1)-way combination. This procedure counts each (t + 1)-way combination C(t + 1, t) = t + 1 times. The covering array contains C(n, t)vt t-way combinations, so the proportion of (t + 1)-way combinations, St+1, in the t-way array is at least

C C

( , ) ( ) ( ) ( , ) n t v n t t

n t v v

t

t

− +

+ /+ 1 =

1 1

1

In most practical cases, the (t + 1)-way coverage of a t-way array will be higher than 1/v.

Một phần của tài liệu introduction to combinatorial testing (Trang 180 - 185)

Tải bản đầy đủ (PDF)

(333 trang)