Yu Lei and K. C. Tai
Department of Computer Science
North Carolina State University
Raleigh, NC 27695-7534, USA
fylei2,[email protected]
February 14, 2001
Abstract
Pairwise testing (or 2-way testing) is a specication-based testing criterion, which requires that for each pair of input parameters of a system, every combination of valid values of these two parameters be covered by at least one test case. Empirical results show that pairwise testing is eective for various types of software systems. In this paper, we propose a test generation strategy, called in-parameter-order (or IPO), for pairwise testing. For a system with two or more input parameters, the IPO strategy generates a pairwise test set for the rst two parameters, extends the test set to generate a pairwise test set for the rst three parameters, and continues to do so for each additional parameter. The IPO strategy allows the use of local optimization techniques for test generation and the reuse of existing tests when a system is extended with new parameters or new values of existing parameters. We present practical, IPO-based test generation algorithms. We describe the implementation of an IPO-based test generation tool and show some empirical results.
1 Introduction
Pairwise testing (or 2-way testing) is a specication-based testing criterion, which requires that for each pair of input parameters of a system, every combination of valid values of these two parameters be covered by at least one test case. Empirical results show that pairwise testing is practical and eective for various types of software systems [1] [2] [3] [5] [6].
To illustrate the concept of pairwise testing, consider a system with parameters and values as shown below:
parameter
A
has valuesA
1 and
A
2, parameterB
has valuesB
1 and
B
2, and parameterC
has valuesC
1,
C
2 andC
3.For parameters
A
andB
,f(A
1
;B
1), (A
1;B
2), (A
2;B
1), (A
2;B
2)g is the only pairwise test set.
f(
A
1
;B
1;C
1), (A
1;B
2;C
2), (A
2;B
1;C
3), (A
2;B
2;C
1), (A
2;B
1;C
2), (A
1;B
2;C
3) g, f(A
1
;B
1;C
1), (A
1;B
2;C
1), (A
2;B
1;C
2), (A
2;B
2;C
3), (A
2;B
1;C
1), (A
1;B
2;C
2), (A
1;B
1;C
3) g f(A
1
;B
1;C
1), (A
1;B
2;C
1), (A
2;B
1;C
2), (A
2;B
2;C
2), (A
2;B
1;C
1), (A
1;B
1;C
2), (A
1;B
1;C
3),(
A
2;B
2;C
3) g.Dierent test generation strategies have been published for pairwise testing. The strategy proposed in [1] starts with an empty test set and adds one test at a time. To generate a new test, the strategy produces a number of possible candidate tests according to a greedy algorithm and then selects one that covers the most uncovered pairs.
Another approach to generating a pairwise test set is to use orthogonal arrays. The original method of orthogonal arrays requires that all parameters have the same number of values and that each pair of values be covered the same number of times [8]. The rst requirement can be relaxed by adding don't care values for missing values. But the use of don't care values creates extra tests [9]. The second requirement is considered unnecessary for software testing and also creates extra tests for pairwise testing [1].
In this paper, we propose a new test generation strategy, called in-parameter-order (or IPO), for pairwise testing. For a system with two or more input parameters, the IPO strategy generates a pairwise test set for the rst two parameters, extends the test set to generate a pairwise test set for the rst three parameters, and continues to do so for each additional parameter. The extension of an existing pairwise test set for an additional parameter contains the following two steps: (a) horizontal growth, which extends each existing test by adding one value of the new parameter, and (b) vertical growth, which adds new tests, if necessary, after the completion of horizontal growth.
The remainder of this paper is organized as follows. Section 2 describes the IPO strategy and its advantages and also shows an optimal algorithm for vertical growth, which can be used in conjunction with any algorithm for horizontal growth. Section 3 presents two algorithms for horizontal growth. Section 4 describes an IPO-based test generation tool and shows some empirical results. Section 5 concludes this paper. This paper is an extended version of our earlier paper published in [7].
2 In-Parameter-Order (IPO) Strategy for Generating Pairwise
Test Sets
2.1 Framework of the IPO Strategy
Assume that system S has parameters
p
1
;p
2;:::
, andp
n,n
2. Below is a general description of
the IPO strategy for generating a pairwise test set T forS.
Strategy
In-Parameter-Orderbegin
/* for the rst two parameters
p
1 andp
2 */ T := f(v
1
;v
2) jv
1 and
v
2 are values ofp
1 andp
2 respectively gif
n
= 2then
stop;/* for the remaining parameters */
for
parameterp
i;i
= 3;
4;::: ;n
do
begin
/* horizontal growth */
for
each test (v
1;v
2;:::;v
i?1) in Tdo
replace it with (
v
1;v
2;:::;v
i?1;v
i), wherev
i is a value ofp
i;/* vertical growth */
while
T does not cover all pairs betweenp
iand each of
p
1;p
2;:::;p
i?1do
add a new test for
p
1;p
2;:::;p
i to T;end
end
The IPO test generation strategy for pairwise testing provides the following advantages:
The IPO strategy allows the use of \local" optimization techniques for horizontal and vertical
growth in order to develop practical test generation algorithms. (We will show how to do so in sections 2.2 and 3.)
Assume thatT is a pairwise test set for a systemS. Suppose that a new version ofS has one
or more new parameters. By applying the IPO strategy, we can easily extend T to produce
a new pairwise test setT
0 for the new version of
S. Furthermore, since T
0 reuses tests in T,
the eort for test preparation according to T
0 is less than that according to a new pairwise
test set without reusing tests inT.
Assume that T is a pairwise test set for a system S. Suppose that S has a new version in
which some parameters have new values. By applying the vertical growth in the IPO strategy, we can easily extend T by adding new tests to produce a new pairwise test set T
0 for the
new version of S. T
0 may be larger than a pairwise test set generated by applying the IPO
strategy without reusingT. However, T
0 can save eort for test preparation due to the reuse
of tests inT.
2.2 An Optimal Algorithm for Vertical Growth
We rst use the example system in Section 1 to illustrate our algorithm for vertical growth. As mentioned earlier, f(
A
1
;B
1);
(A
1;B
2), (A
2;B
1), (A
2;B
2)(
A
1;B
1;C
1), (A
1;B
2;C
1), (A
2;B
1;C
2), and (A
2;B
2;C
2). These four tests do not cover pairs(
A
1;C
2);
(A
1;C
3);
(A
2;C
1);
(A
2;C
3);
(B
1;C
3) and (B
2;C
3). So we need to generate new tests tocover these pairs in vertical growth. (
A
1;C
2) is covered by test (A
1;
?;C
2), where "
?" denotes
don't care, meaning that the value does not need to be specied for covering any pair. Similarly, (
A
1;C
3), (A
2;C
1), and (A
2;C
3) are covered by (A
1;
?
;C
3), (
A
2;
?;C
1) and (
A
2;
?;C
3) respectively.
To cover (
B
1;C
3), we change (A
1;
?;C
3) to (
A
1;B
1;C
3) without adding a new test. Similarly, wecover (
B
2;C
3) by changing (A
2;
?;C
3) to (
A
2;B
2;C
3). Thus, we generate four new tests to coverthe six missing pairs. (Note that it is impossible to use less than four tests to cover the six missing pairs.) So the generated pairwise test set has a total of eight tests.
Assume that the horizontal growth for parameter
p
i has produced a test set T forp
1
;p
2;:::;
and
p
i. (Thus, T is resulted from the extension of a pairwise test set forp
1
;p
2;:::
andp
i?1.) Let be the set of missing pairs according to T. Each pair in contains a value ofp
i and a value ofone of
p
1;p
2;:::;p
i?1. Assume thatj
j>
0. Letd
j, 1j
i
, be the domain size of parameterp
jand
m
j =max
fd
kj1k
j
g. The following algorithm for vertical growth shows how to constructa minimum test setT
0 such that T [T
0 is a pairwise test set for
p
1
;p
2;:::
andp
i.Algorithm
IPO V(T;
)/*
is the set of missing pairs according to a test set T forp
1
;p
2;:::;
andp
i. This algorithmconstructs a minimum test set T
0 such that T [T
0 is a pairwise test set for
p
1,
p
2;:::;
andp
i. */begin
let
be a two-dimension (d
im
i) array of tests, and let initialized withtests that have all the values as \?";
let
be an array of integers of sized
i initialized with 0;for
each pair (p
k:w;p
i:u
) indo
begin
let
u
be thej
th value ofp
i;for
l
= 1to
[j
]do
;begin
if
[j
][l
] has \?" as the value ofp
k and \u
" as the value ofp
ithen
begin
modify
[j
][l
] by replacing the \?" withw
;break
;end
end
if
l >
[j
]then
begin
[j
] + +;modify
[j
][[j
]] such thatw
is the value ofp
k andu
is the value ofp
i;end
end
; letT0 be an empty set;
for
r
= 0to
d
ido
begin
begin
add
[r
][s
] intoT 0;end
end
return
T0;
end
;Assume that
p
i contains valuesu
1;u
2;:::
andu
q. For 1j
q
, letj be the set of pairs inthat contain
u
j as the value ofp
i. Ifjjj>
0, letjm, 1m
i
?1, be the set of pairs of j thatcontain a value of
p
m. The number of new tests according to j ismax
fjjmjjm
= 1;
2;::: ;i
?1g.The set of new tests according to
j is minimum, since it is impossible to cover pairs in j withless number of tests. Furthermore, the set of new tests according to
j cannot cover pairs that arein
, but not inj. Thus, the above algorithm constructs a minimum set of new tests accordingto
. Therefore, we have the following theorem.Theorem 2.1
LetS
be a system with parametersp
1;p
2;:::;
andp
i. Assume that according to theIPO strategy, the vertical growth for parameter
p
i has produced a test set T forp
1
;p
2;:::;
andp
i.Let
be the set of missing pairs according to T. Algorithm IPO V constructs a minimum set T 0of new tests according to
such that T [T0 is a pairwise test set for
S
.The time complexity of algorithm IPO V is dominated by the rst for loop, which has a nested loop. The size of
is at mostd
iPi ?1
j=1
d
j, which is less than or equal tom
2i (
i
?1). For each pair(
p
k:u;p
i:v
) in , the nested loop searches the tests withv
as the value ofp
i to determine if thereexists one with \?" as the value of
p
k among those tests. There are at mostm
i tests withv
asthe value of
p
i, each of which can be checked inO
(1). So the nested loop takesO
(m
i). The timecomplexity of algorithm IPO V is therefore
O
(m
3i
i
). For a system withn
parameters, algorithmIPO V is executed for
i
= 3 ton
. Letd
=max
fd
ij1i
n
g. Thus, the total execution time foralgorithm IPO V is
O
(d
3n
2).
Theorem 2.2
LetS
be a system withn
parameters and letd
be the maximum domain size of these parameters. According to the IPO strategy, the size of the pairwise test set generated forS
is at mostd
2(
n
?1).Proof
Forn
= 2, the size of the generated pairwise test set is at mostd
2. Forn
= 3, horizontalgrowth does not increase the number of tests generated for
n
= 2, and vertical growth adds at mostd
2 tests. So the size of the generated test set forn
= 3 is at mostd
22. By using the same
argument, the size of the generated pairwise test set for any system with n parameters is at most
d
2(
n
?1). 2In practice, as shown in Section 4, the sizes of test sets generated by PairTest are
O
(d
2log(
n
)).3 Two Algorithms for Horizontal Growth
Assume that T is a pairwise test set for parameters
p
1
;p
2;:::;
andp
i?1. As mentionedear-lier, the horizontal growth for parameter
p
i is to replace each test (v
1;v
2;:::;v
i?1) in(
v
1;v
2;:::;v
i?1;v
i), wherev
i is a value ofp
i. Thus, the horizontal growth forp
i is to construct alist ofjTjvalues of parameter
p
i such that thej
th value of the list, 1j
jTj, is the value addedto the
j
th test in T. Such a list is referred to as a permutation of parameterp
i forT. There are jD(p
i)jjTjpossible permutations of parameter
p
i forT. For a permutation
of parameterp
i forT,let (T
;
) denote the test set resulted from adding thej
th element of, 1j
jTj, to thej
th testinT.
Ideally, we hope to nd a permutation
of parameterp
i forT such that (T;
) is a minimumpairwise test set for
p
1;p
2;:::;
andp
i. If such a permutation does not exist, we need to choose apermutation
of parameterp
i forT such that the set of new tests constructed by algorithm IPO V(shown in Section 2.2) according to the set of missing pairs based on (T
;
) is minimum. Sincethere arejD(
p
i)jjTjpossible permutations of parameter
p
i forT, nding an \optimal" permutation
by exhaustive search is very time-consuming. In section 4.1, we show an algorithm for horizontal growth, called IPO H EC (\EC" stands for \equivalence classes"). This algorithm nds an optimal permutation of parameter
p
i forT without using exhaustive search. However, algorithm IPO H ECstill has exponential time complexity. In section 4.2, we show algorithm IPO H IV (\IV" stands for \individual values"), which is practical to use.
3.1 Algorithm IPO H EC
Denition 1
Let T be a pairwise test set for parametersp
1
;p
2;:::;
andp
i?1. For a permutation of parameterp
i for T, let the weight of with respect to T, orweight
(;
T), be dened as thenumber of new tests constructed by algorithm IPO V according to the set of missing pairs based on (T
;
).The motivation for algorithm for IPO H EC is that the set of permutations of parameter
p
iwith sizejTjcan be divided into equivalent classes such that permutations in the same class have
the same weight with respect to T. Thus, nding an optimal permutation of parameter
p
i for T requires only the use of one permutation from each equivalent class. Below we show severaldenitions and theorems that are necessary for understanding algorithm IPO H EC. Proofs for the theorems in this section are shown in the appendix.
Denition 2
Let and be two permutations of a parameter such that = (u
1;u
2;:::;u
n) and = (v
1;v
2;:::;v
n). An onto mapping from to is a 1-to-1 function from to such thatv
i= (u
i).Denition 3
Two dierent permutations and of a parameter are said to be equivalent, noted as , provided that there exists an onto mapping from to or vice versa.For the example system in Section 1, consider the following two permutations of parameter C:
C
0 = (C
1,
C
1,C
2,C
3) andC
00 = (
C
2,
C
2,C
1,C
3). According to the above denitions, the twopermutations are equivalent due to the existence of the following 1-to-1 function from
C
0 toC
00:(
u
) =8 > < > :
Theorem 3.1
Let T be a pairwise test set for parametersp
1
;p
2;:::;
andp
k?1. For twopermu-tations
and of parameterp
i with respect to T, if and are equivalent, thenweight
(;
T) =weight
(;
T).To illustrate the above theorem, consider again the example system in Section 1. T =f(
A
1;B
1),(
A
1;B
2), (A
2;B
1), (A
2;B
2)g is a pairwise test set for parameters A and B. As shown earlier,
C
0=(
C
1;C
1;C
2;C
3) andC
00 = (C
2
;C
2;C
1;C
3) are equivalent. To calculateweight
(C
0;
T), we construct
(T
;C
0), which is f(
A
1
;B
1;C
1), (A
1;B
2;C
1), (A
2;B
1;C
2), (A
2;B
2;C
3)g. The set of missing pairs
is f(
A
2
;C
1), (A
1;C
2), (B
2;C
2), (A
1;C
3), (B
1;C
3)g, which is covered by the new test set T 0 = f(
A
2
;
?;C
1), (
A
1;B
2;C
2), (A
1;B
1;C
3)g. Thus,
weight
(C
0;
T) = 3. To calculate
weight
(C
00;
T),
we construct (T
;C
00), which is f(
A
1
;B
1;C
2), (A
1;B
2;C
2), (A
2;B
1;C
1), (A
2;B
2;C
3)g. The set of
missing pairs isf(
A
2
;C
2), (A
1;C
1), (B
2;C
1), (A
1;C
3), (B
1;C
3)g, which is covered by the new test
set T 00 =
f(
A
2;
?
;C
2), (
A
1;B
2;C
1), (A
1;B
1;C
3)g. Thus,
weight
(C
00;
T) = 3. Note that although T 0 6 =T 00, jT 0
j=jT 00
j= 3 .
By Theorem 3.1, nding an optimal permutation of parameter
p
i for T requires only the useof one permutation from each equivalent class of permutations of sizejTjof
p
i. Thus, the numberof permutations considered for choosing an optimal permutation can be signicantly reduced. The following theorem shows how to determine the number of equivalent classes of permutations of size
jTjof
p
i .Theorem 3.2
Assume that parameter has domain D, where jDj=d
. Let M be the set of all 's permutations with sizem
. Let N(m;d
) be the number of equivalence classes in M.N(
m;d
) = (1
if
d=1;
m=1or
0P
mi=1(
C
i?1
m?1
N(
m
?i;d
?1))otherwise
As an example, for a parameter having 4 values, the number of dierent permutations of size 10 is 410= 1048576, but the number of equivalence classes of these permutations is
N(10
;
4) = 43947.Since N(
m;d
) 2m ?1,N(
m;d
) is an exponential function ofm
. For a given parameter andpermutation size, the following theorem shows how to construct a set of permutations such that this set contains exactly one permutation from each equivalence class.
Theorem 3.3
Assume that parameter has domain D, where jDj=d
. Let D =fv
1
;v
2;:::;v
d gand Di =f
v
d?i+1
;v
d?i+2;:::;v
dg, where 1
i
d
. Let E(m;
D) be dened as follows:E(
m;
D) = 8 > > > > > < > > > > > :fg
if
m = 0f(
v
1)g
if
m = 1f
m
z }| {
(
v
1;v
1;:::;v
1)g
if
jDj= 1[mi =1([
B] (m;i)
v1 jb
1 =v
1
E(
m
?i;
Dd?1))
otherwise
E(
m;
D) contains exactly one permutation of with sizem
from each equivalence class ofpermutations of
with sizem
. (Note that [B] (m;i)v1 jb
1 =v
1 and \*" operator are not dened here since
their denitions are complicated. Please see the appendix for their denitions.)
such permutations, but they can be divided into 14 equivalent classes according to Theorem 3.2. Below are 14 permutations of size 4 of parameter C, one from each equivalent class: f(
C
1,
C
1,C
1,C
1), (C
1,C
1,C
1,C
2),(C
1,C
1,C
2,C
1), (C
1,C
2,C
1,C
1), (C
1,C
1,C
2,C
2), (C
1,C
1,C
2,C
3),(
C
1,C
2,C
1,C
2), (C
1,C
2,C
1,C
3), (C
1,C
2,C
2,C
1), (C
1,C
2,C
3,C
1), (C
1,C
2,C
2,C
2), (C
1,C
2,C
2,C
3), (C
1,C
2,C
3,C
2), (C
1,C
2,C
3,C
3)g. We choose one of these 14 permutations that
has the minimum weight, and this permutation has the minimum weight among all possible 81 permutations. Note that for the example in Section 2.2, the horizontal growth for parameter
C
uses the permutation (
C
1;C
1;C
2;C
2), which has 4 as its weight. It was shown earlier that theweight for (
C
1;C
1;C
2;C
3) is 3. Later we will show that the weight for (C
1;C
2;C
3;C
1) is 2, whichis the minimum weight.
Below we show algorithm IPO H EC for horizontal growth.
Partition
(p;m
) returns a set of permutations of parameterp
i with sizem
according to Theorem 3.3. The main loop of IPO H ECnds a permutation with the minimum weight, which is used to perform the horizontal growth.
Algorithm
IPO H EC(T,p
i)/* T is a pairwise test set for parameters
p
1
;p
2;:::;
andp
i?1. This algorithm selects an optimalpermutation
ofp
i of size jTjand replaces T with (T;
). */begin
/* Initialization */
=null
;!
=1;/* Main Loop */
M:=
Partition
(p
i;
jTj);for
each permutation0 in Mdo
begin
!
0 :=weight
(0;
T);if
!
0!
then
=0;!
=!
0;end
replaceT with (T
;
);end
function
Partition(p
,m
)begin
let D=f
v
1
;v
2;:::;v
jDjgbe the domain of
p
;for
i
= 1to
m
E(i;
D1) = f(
v
1) g
for
i
= 2to
jDjfor
j
= 1to
m
E(i;
Dj) =fg;for
k
= 1to
j
E(
i;
Dj) =E(i;
Dj)[([B] (j;k)vi jb
1=v i
E(
j
?k;
Dj ?1));3.2 Algorithm IPO H IV
Since algorithm IPO H EC has exponential time complexity, it is not practical for systems with a large number of parameters. In this section, we show a horizontal growth algorithm that is practical to use, but may produce more tests than algorithm IPO H EC. Assume that T is a pairwise test
set for parameters
p
1;p
2;:::;
andp
i?1. Initially, the set of missing pairs contains all possiblepairs between values of
p
i andp
1;p
2;:::;
andp
i?1. For each test inT, we consider all values of
p
i,choose one that covers the most number of pairs in
, extend the test by adding the chosen value ofp
i, and remove from pairs covered by the extended test. Thus, we incrementally construct apermutation of
p
i with sizejTjby choosing one value ofp
i for each test inT
.Assume that the domain of
p
i contains valuesv
1;v
2;:::
, andv
q. IfjTj
q
, we can simplychoose
v
j, 1j
jTj, as the new value for thej
th test inT, since the resulting test covers exactlyi
?1 missing pairs. (In fact, we can choose any permutation ofp
i of sizejTjsuch that all elementsof this permutation are distinct.) If jTj
> q
, for 1j
q
, we choosev
j as the new value forthe
j
th test in T, and forj > q
, we consider all values ofp
i and choose one that covers the mostnumber of missing pairs.
Now we apply the above discussion to the example system in Section 1. f(
A
1
;B
1), (A
1;B
2),(
A
2;B
1), (A
2;B
2)g is the only pairwise test set for A and B. Since C has three values
C
1,C
2and
C
3, we extend (A
1;B
1), (A
1;B
2) and (A
2;B
1) by addingC
1,C
2 andC
3, respectively. Theextended tests are (
A
1;B
1;C
1), (A
1;B
2;C
2) and (A
2;B
1;C
3), and the resulting set of missing pairsis f(
A
2
;C
1), (B
2;C
1), (A
2;C
2), (B
1;C
2), (A
1;C
3), (B
2;C
3)g. Now we need to choose one of
C
1,C
2, andC
3 for (A
2;B
2). If we addC
1 to (A
2;B
2), the extended test (A
2;B
2;C
1) covers two missingpairs (
A
2;C
1) and (B
2;C
1). If we addC
2 to (A
2;B
2), the extended test (A
2;B
2;C
2) covers onlyone missing pair (
A
2;C
2). If we addC
3 to (A
2;B
2), the extended test (A
2;B
2;C
3) covers onlyone missing pair (
B
2;C
3). Thus we choose (A
2;B
2;C
1) as the fourth test. As a result, we havefour missing pairs: (
A
2;C
2), (B
1;C
2), (A
1;C
3), and (B
2;C
3). By applying algorithm IPO V, wegenerate tests (
A
2;B
1;C
2) and (A
1;B
2;C
3) to cover these missing pairs.Below we show the complete algorithm, which is called IPO H IV, where \IV" stands for \in-dividual values". For 1
j
i
, letd
j be the domain size of parameterp
j andm
j =max
fd
kj1k
j
g.Algorithm
IPO H IV(T,p
i)/* T is a pairwise test set for parameters
p
1
;p
2;:::;
andp
i?1. This algorithm modies T byadding a value of
p
i to each test inT */.begin
/* initialization */
let
be a three-dimension (d
i(i
?1)m
i) array of booleans initialized withfalse
let
be a two-dimension (d
i(i
?1)) array of integers initialized with 0s
=min
(jD(p
i)j;
jTj);/* no need to select values of
p
i */for
j
= 1to
s
do
begin
extend the
j
th test inT by adding thej
th value ofp
i;mark(T,
p
i,j
,,);end
;/* necessary to select values of
p
i */for
j
=s
+ 1 to jTjdo
begin
w
0:= 0;for
each valuev
inp
ido
begin
w
= eval(T,p
i,j
,,);if
w
0< w
begin
w
0 :=w
;v
0 :=v
;end
;end
;extend the
j
th test inT by adding valuev
0;mark(T,
p
i,j
,,);end
;end
;function
mark(T,p
i,j
,, )begin
let
be thej
th test inT;let
v
be the value ofp
i in, and letv
be thek
th value ofp
i;for
l
= 1to
i
?1do
begin
let
w
be the value ofp
l in, and letw
be then
th value ofp
l;if
w
6= \?00
then
[k
][l
][n
] =true
;else
begin
q
=[k
][l
];if
q
6=?1begin
replace
w
as theq
th value ofp
l;for
t
=q
+ 1to
d
ldo
begin
if
![k
][l
][t
]break
;end
if
t
d
lthen
update[k
][l
] with thet
th value ofp
l;else
[k
][l
] :=?1;end
end
end
end
function
eval(T,p
i,j
,,)begin
r
= 0;let
be thej
th test inT;let
v
be the value ofp
i in, and letv
be thek
th value ofp
i;begin
let
w
be the value ofp
l in, and letw
be then
th value ofp
l;if
w
6= \? 00begin
if
[k
][l
][n
] =false
then
r
+ +;end
else
begin
if
[k
][l
]6=?1then
r
+ +;end
end
return
r
;end
In the above algorithm, a coverage matrix
and a pointer matrix are maintained for the purpose of eciency. Cis used to determine whether a pair is covered or not inO
(1). Given a pair(
p
k:u;p
i:v
), where assume thatu
is thei
th value of parameterp
k andv
thej
th value of parameterp
i, (p
k:u;p
i:v
) is covered if and only if[j
][k
][i
] =true
. P is used to deal with \?" values. [j
][k
] =l
means that the pair (
p
k:u;p
i:v
), whereu
is thel
th value of parameterp
k andv
thej
th value ofparameter
p
i, has not been covered yet. Therefore, a \?" value of parameterp
k can be replacedwith the
l
th value of parameterp
k to cover a new pair.Now we consider the time complexity of algorithm IPO H IV. The mark function is used to maintain
and whenever a test is extended by adding one value ofp
i. For each pair, mark takesO
(1) to update, andO
(m
i) to update. Considering that an extended test hasi
?1 pairs, mark hasthe time complexity of
O
(m
ii
). The eval function determines the number of new pairs covered by atest if the test were extended by a given value of
p
i. It takesO
(1) for eval to check one pair, andO
(i
)for all the
i
?1 pairs covered by a test. The time complexity of algorithm IPO H IV is dominatedby the second for loop, which has a nested for loop. The nested loop takes
O
(i
m
i), sinced
i valuesof
p
i are evaluated, each of which takesO
(1)toevaluate
. The invocation of mark takesO
(i
m
i) asmentioned earlier. Assume that the sizes of test sets generated by IPO are
O
(m
2ilog(
i
)), the timecomplexity of algorithm IPO H IV is
O
(m
2i log(
i
)m
ii
) =O
(m
3i log (
i
)i
). For a systemwith
n
parameters, algorithm IPO H IV is executed fori
= 3 ton
. Letd
=max
fd
ij1i
n
g.Thus, the total execution time for algorithm IPO H IV is
O
(d
3n
2
log (
n
)).4 PairTest: An IPO-based Test Generation Tool
We have implemented an IPO-based test generation tool, called PairTest, that includes algorithm IPO H IV for horizontal growth and algorithm IPO V for vertical growth. We have also imple-mented algorithm IPO H EC, but does not include it in PairTest due to its exponential time complexity.
Major features of PairTest include the following:
PairTest supports the generation of pairwise test sets for systems with or without existing
PairTest provides information for planning the eort of testing and the order of applying test
cases.
PairTest provides a graphical user interface (GUI) to make the tool easy to use. PairTest was written in Java and thus can run on dierent platforms.
PairTest supports the following types of test generation:
For a system without an existing test set, PairTest generates a pairwise test set.
For a system with an existing test set, PairTest allows two options. One is to generate a new
pairwise test set, without reusing the existing test set. The other is to keep the existing test set and generate additional tests, if necessary, such that the combined test set is a pairwise test set. The combined test set produced by the second option may be larger than the new test set produced by the rst option. However, the second option allows the reuse of tests and thus can save the eort for test preparation.
For a system that has an existing test set and is being modied due to changes of parameters,
values, relations and constraints1, PairTest allows two options. One is to generate a new
pairwise test set, without reusing the existing test set. The other is to modify the existing test set and then generate additional tests, if necessary, such that the combined test set is a pairwise test set.
Another test generation tool for pairwise testing is AETG (Automatic Ecient Test Generator)3
[1] [2]. We used AETG4 to produce pairwise test sets for the six systems mentioned in [2]. We
also used PairTest to generate pairwise test sets for the same six systems. Table 1 shows the size information produced by AETG and PairTest for these six systems. As shown in Table 1, each of AETG and PairTest produces smaller test tests than the other for some systems. Since the execution time information on test sets generated by AETG is not available, it is impossible to compare AETG and PairTest in terms of actual time taken for test generation. Later we will show that Pairwise has lower time complexity than AETG.
It was shown that for a system with
n
parameters, each havingd
values, the size of a minimum pairwise test set grows at most logarithmically inn
and quadratically ind
[2]. Empirical results based on AETG indicates that when the number of candidate test cases for a new test case is 50, the number of test cases grows logarithmically in n [2]. We have carried out empirical studies to determine the growth function for the size of a pairwise test set generated by PairTest in terms ofn
andd
. Table 2 shows the sizes of test sets generated by PairTest for systems withd
= 4 and dierent values ofn
. Table 3 shows the sizes of test sets generated by PairTest for systems withn
= 10 and dierent values ofd
. According to statistic analysis, the values of s (number of tests) in Tables 2 and 3 grow inO
(log(n
)) andO
(d
2) respectively. These empirical results match thetheoretical results mentioned earlier.
Tables 2 and 3 also show time information for test sets generated by PairTest. The execution time information was collected when PairTest was compiled and run on a PC with Intel 450MHZ
1Relations and constraints are used to allow variations of pairwise testing according to the user's needs [2]. 3AETG is a trademark of Telcordia Technologies Inc. and is covered by United States Patent 5,542,043.
Table 1: Sizes of pairwise test sets generated by AETG and PairTest System S1 S2 S3 S4 S5 S6
AETG 11 17 35 25 12 193 PairTest 9 17 34 26 15 212 S1: 4 3-value parameters
S2: 13 3-value parameters
S3: 61 parameters (15 4-value parameters, 17 3-value parameters, 29 2-value parameters) S4: 75 parameters (1 4-value parameter, 39 3-value parameters, 35 2-value parameters) S5: 100 2-value parameters
S6: 20 10-value parameters
Pentium II processor, Windows 98 and JDK 1.2.2. According to statistic analysis, the values of
t
(time for test generation) in Tables 2 and 3 grow in
O
(n
2log (
n
)) andO
(d
3) respectively. Based
on the observation that the size of a test set generated by PairTest is
O
(d
2log(
n
)), we haveshown that the time complexity of the IPO strategy is
O
(d
3n
2
log(
n
)). Thus, our empiricalresults match our analytic results. Based on the same observation for AETG, we have also shown that the time complexity of the AETG heuristic algorithm in [2] is
O
(d
4n
2log (
n
)) (as shownin Theorem 4.1).
Table 2: Results of PairTest for systems with
n
4-value parametersn (# of parameters) 10 20 30 40 50 60 70 80 90 100 s (# of tests) 31 34 41 42 48 48 51 51 51 53 t (time in seconds) 0.11 0.16 0.22 0.44 0.77 0.99 1.37 1.81 2.23 2.96
Table 3: Results of PairTest for systems with 10 parameters, each having
d
values d (# of values) 5 10 15 20 25 30s (# of Tests) 47 169 361 618 956 1355 t (time in seconds) 0.05 0.28 0.72 1.54 2.96 5.16
5 Conclusion
and IPO V, have polynomial time complexities and thus are practical to use. We have constructed a test generation tool, called PairTest, which implements algorithms IPO H IV and IPO V, supports the reuse of existing test sets, and provides graphical user interface. Our empirical results indicate that (1) the size of a pairwise test set generated by PairTest grows logarithmically in the number of parameters and quadratically in the number of values in each parameter, and (2) PairTest is very ecient for generating pairwise test sets. As mentioned earlier, pairwise testing (or 2-way testing) is a special case of
n
-way testing. The IPO strategy and the algorithms presented in the paper can be easily extended for n-way testing.Acknowledgment
This research was supported in part in part by NSF grant CCR-9320992 and a grant from IBM in Research Triangle Park, North Carolina. The authors would like to thank Mr. Ho-Yen Chang for his eort on implementing the PairTest tool.
References
[1] D. M. Cohen, S. R. Dalal, M. L. Fredman, and G. C. Patton. The combinatorial desgin approach to automatic test generation. IEEE Software, pages 83{87, September 1996.
[2] D. M. Cohen, S. R. Dalal, M. L. Fredman, and G. C. Patton. The AETG system: An approach to testing based on combinatorial design. IEEE Transactions on Software Engineering, 23(7):437{443, July 1997. [3] D. M. Cohen, S. R. Dalal, A. Kajla, and G. C. Patton. The automatic ecient test generator. Proc.
IEEE Int. Symp. Software Reliability Engineering, pages 303{309, 1994.
[4] T. H. Cormen, C. E. Leiserson, and R. L. Rivest. Introduction to Algorithms. MIT Press, JULY 1990. [5] S. R. Dalal, A. Jain, N. Karunanithi, J. M. Leaton, and C. M. Lott. Model-based testing of a highly
programmable system. Proc. IEEE Int. Symp. Software Reliability Engineering, pages 174{178, 1998. [6] I. S. Dunietz, W. K. Ehrlich, B. D. Szablak, C. L. Mallows, and A. Iannino. Applying design of
exper-iments to software testing. Proceedings of the Nineteenth International Conference on Software Engi-neering, pages 205{215, May 1997.
[7] Y. Lei and K. C. Tai. In-parameter-order: A test generation strategy for pairwise testing. Proc. 3rd IEEE High-Assurance Systems Engineering Symposium, pages 254{261, Nov 1998.
[8] R. Mandl. Orthogonal latin squares: An application of experimental design to compiler testing. Comm. ACM, pages 1054{1058, October 1985.
6 Appendix
Theorem 3.1
Let T be a pairwise test set for parametersp
1
;p
2;:::;
andp
k?1. For twopermuta-tions
and of parameterp
i for T, if and are equivalent, thenweight
(;
T) =weight
(;
T).Proof
Assumep
i hasd
valid valuesv
1;v
2;:::;v
d. Let be the set of missing pairs if we addintoT. Let
0 be the set of missing pairs if we add
intoT. We make a distribution of
and get'
ij, where 1i
d
and 1j
k
, to represent the set of missing pairs betweenp
i andp
j withthe value
v
i forp
i. We also make similar distribution of0 and get'
0ij. Since
, there exists anonto mapping from
to . Letv
l = (v
i), then j'
ijj=j'
0ljj. Further, P
di=1
max
kj=1fj
'
ijj)g = Pdl=1
max
kj =1fj
'
0ljj)g. We thus conclude that
weight
(;
T) =weight
(;
T). 2Theorem 3.2
Let and be dierent permutations of such that = (u
1;u
2;:::;u
n), =(
v
1;v
2;:::;v
n), and and are equivalent. For eachw
in the domainD of
, there are noi
andj
(1i;j
n
), such thatw
=u
i =v
i^w
=u
j 6=v
j.Proof
Since , there exists an 1-to-1 function from to . Sinceu
i =u
j =w
, then(
u
i) = (u
j), that is,v
i=v
j. We thus complete the proof. 2Denition 4
Assume that parameter has domain D. Let M be the set of all 's permutationswith size
m
. Assume that a dummy parameter has a domain of boolean values: 0 and 1. LetB bethe set of all the dummy parameter's permutations with size
m
. A project function'
:MD!Bis dened as follows. Let
= (u
1;u
2;:::;u
m)2 M and
v
2 D. Let%
='
(;v
). Then,%
=(
b
1;b
2;:::;b
m)2B, where
b
i=(
1
u
i=v
0
u
i6=v
Denition 5
Given a project function'
:MD!B. Letv
2D. The (appearance) pattern setof
v
for all 's permutations with sizem
is dened as [B]mv =f%
2Bj%
='
(;v
)^ 2Mg.%
isalso referred as an (appearance) pattern of
v
.Denition 6
Suppose a parameter has the (appearance) pattern set[B]mv for a valid valuev
forall permutations with size
m
. Let%
= (b
1;b
2;:::;b
m)2[B]mv. The weight of
%
isj%
j= Pmi=0
b
i. Wealso dene [B] (m;i)
v =f
%
j%
2B^j%
j=i
g, [B] (m;i)v jb j
=v k =
f
%
j%
2B^j%
j=i
^b
j =v
kg.Theorem 3.3
Assume that parameter has domain D, where jDj=d
. Let M be the set of all 's permutations with sizem
. Let N(m;d
) be the number of equivalence classes in M.N(
m;d
) = (1
if
d=1;
m=1or
0P
mi=1(
C
i?1
m?1
N(
m
?i;d
?1))otherwise
Proof
Let us consider the boundary cases rst. Whenm
= 1, each permutation consists of a single value of. Obviously, all single-value permutations are equivalent. Then,N(1;d
) = 1. Whend
= 1, the parameter has the only value, sayv
, to take. Regardless ofm
, the only permutation is formed by lling in all of the positions byv
. Thus,N(m;
1) = 1.we dene two functions: (1)
: M ! D, where () =v
1 for
= (v
1;v
2;:::;v
m)2 M; (2)
u!v :
M ! M, where u
!v(
u
1;u
2;:::;u
m) = (v
1;v
2;:::;v
m) withv
i =v
ifu
i =u
,v
i =u
ifu
i =v
andv
i =u
i otherwise.Suppose
hasd
valuesv
1;v
2;:::;v
d. We divideM into
d
groups M 1;
M 2
;:::;
Md, where Mi =f
2 Mj() =v
ig. We show that 8i;j
89( 2 Mj ^ 2 Mi^ ). Given 2 Mj,let
= vj!vi(
). Obviously, . Since() = ( v j!vi(
)) =v
i,2 Mi. Intuitively, if we
pick up one group Mi, then 8
2Mj(j
6=i
), we can always locate a permutation 2Mi, whichmakes
. By Theorem 3.1, we conclude that it is sucient for us to examine only one group ofpermutations.
Without loss of generality, we pick upM 1. Let
j
v 1jbe the number of
v
1's in
, where 2M1.
Then, 1j
v 1j
m
. We make a distribution ofM1 and get M
1iwhere M
1i=
f
2M 1jj
v 1j=
i
g.Let us consider M
1i. Then,
8
( 2 M 1i^
() =v
1^j
v 1j =
i
). By the theory of combination, j[B](m;i)
v1 jb
1 =v
1 j=
C
i?1
m?1 considered that the rst position is always occupied by
v
1. Obviously, for
any pattern
%
2 [B] (m;i)v1 jb
1=v
1,
%
xesi
positions byv
1, but leaves
m
?
i
positions unxed. Notethat
v
1 does not appear in the unxed positions. Thus,%
hasN(
m
?i;d
?1) permutations by ournotation.
Note that all the permutations in M
1 has dierent (appearance) patterns. Consider any two
permutations (
u
1;u
2;:::;u
3) and (v
1;v
2;:::;v
3). Sincev
1 always shows up in the rst position,there must be some position
i
such thatu
i =v
1 (orv
i =v
1) butu
i6
=
v
i . By Theorem 3.2,no permutations in M
1 are equivalent. Therefore, the number of equivalence classes in M
1 is j
M
jequiv=N(m;d
) =P
mi=1 M
1i = P
mi=1(
C
i?1
m?1
N(
m
?i;d
?1)).2
Denition 7
Assume a pattern%
= (b
1;b
2;:::;b
m) of a value ofw
. Let j%
ji=P
ij=0
b
j. (Obviously, j%
jm =j%
j.) Let B be a set of patterns of sizem
. Let M be a set of permutations of sizem
?j%
jand M
0 a set of permutations of size
m
. We dene an operator:BM! M
0 as follows. Let
2M, 2M0, and
=%
, Then, = (v
1
;v
2;:::;v
m), wherev
i =(
w
b
i = 1u
i?j%ji
b
i = 0Theorem 3.4
Assume that parameter has domain D, where jDj=d
. Let D =fv
1
;v
2;:::;v
d gand Di =f
v
d?i+1
;v
d?i+2;:::;v
dg, where 1
i
d
. Let E(m;
D) be dened as follows:E(
m;
D) = 8 > > > > > < > > > > > :fg
if
m = 0f(
v
1)g
if
m=1f
m
z }| {
(
v
1;v
1;:::;v
1)g
if
jDj= 1[mi =1([
B] (m;i)
v1 jb
1 =v
1
E(
m
?i;
Dd?1))
otherwise
E(
m;
D) contains exactly one permutation of with sizem
from each equivalence class ofpermutations of
with sizem
.Proof
The conclusion can be easily drawn with being viewed as a constructive restatement ofTheorem 4.1
Assume that a systemS
hasn
parameters, and each parameter has at mostd
valid values. The AETG algorithm presented in [2] generates a pairwise test set forS
inO
(d
4n
2
log (
n
)).Proof
According to [2], the AETG algorithm generates
M
(e.g.M
= 50) candidate tests and selects one that covers the most number of uncovered pairs for each test. Assume that a systemS
hasn
parameters, and the
i
th parameter hasd
i parameters. Also assume that we have selectedr
testcases in the resultant test set
T
. Below we restate the algorithm presented in [2], which is used by AETG to generate a candidate test.Algorithm
AETG Select (S
,T
)begin
choose a parameter
f
and a valuel
forf
such thatl
appears in the greatest number of uncovered pairs; ...(*)let
f
1;:::;f
n be a random order ofn
parameters withf
1 =f
; ...(**)let
l
be the value selected forf
1;for
j
= 2to
n
do
begin
w
0= 0;for
each valuev
off
jdo
begin
=f(u;v
)ju
is the value selected forf
i, 1i
j
g;let
w
be the number of uncovered pairs in;if
w > w
0then
begin
w
0 :=w
;v
0 :=v
;end
end
let
v
0 be the value selected forf
j;
end
end
Now we consider the time complexity of the algorithm AETG Select. Let
d
=max
fd
ij1i
n
g. The number of uncovered pairs isO
(d
2
n
2). In order to nd
f
andl
, statement (*) needs togo through the set of uncovered pairs, which takes
O
(d
2n
2). In statement (**), it takes
O
(n
) togenerate a random order of
n
parameters. Assume that the determination of if a pair is uncovered or not takesO
(1) (this can be done by maintaining a coverage matrix as in algorithm IPO H IV). The size of is inO
(n
). The inner for loop takesO
(d
n
) to calculate the number of uncoveredpairs for each value of
f
j and derive the one which covers the greatest number of uncovered pairs.Considering that the outer for loop iterates through
n
?1 parameters, the nested for loop togethertakes
O
(n
2d
). Therefore, the time complexity of AETG Select isO
(n
2d
2). Assume that
the sizes of test sets generated by AETG are
O
(d
2log (
n
), the time complexity of the AETGalgorithm is
O
(d
4n
2log (
n
)).