Consider the input variables at and tt. Variable at has the following classes {cx}
and {dg}. We can divide the values of tt into the following classes {first, business}
and {economy} and call them C1 and C2. Referring to the precondition of the second
operation of the CreditCard machine, it is clear that class {cx} is coexisting with both
C1 and C2 whereas class {dg} is only coexisting with C1.
6 Test Case Generation
Based on the concepts described in the above sections, the generation of test cases from
a B specification based on class vectors encompasses the following steps:
1. Identification of classes
2. Identification of independent sets of input variables
3. For each independent set of input variables, enumerate all class vectors containing
only coexisting classes
4. Derive the Cartesian product of the independent sets of coexisting class vectors
5. For each class vector of the Cartesian product, select a vector of representative
values as a single test case
For the Credit Card example, we have already identified the independent sets of
input variables in section 4. The coexisting class vectors for these sets are as follows:
{itype} : (visa), (mastercard)
{iclass, b} : (platinum, 0..1000), (platinum, 1001..4000),
(platinum, 4001..8000), (gold, 0..1000),
(gold, 1001..4000), (class, 0..1000)
{ischeme, al, tt, su} : (airticket, cx, {first, business}), (airticket, cx, {economy}),
(airticket, dg, {first, business}), (gift, SUPPLIER)
Taking the Cartesian product of the above sets yields 2 × 6 × 4 = 48 different class
vectors, from which we can derive 48 legitimate test cases.
7 Discussion
The concept of a class (of input values) goes back to the classification tree method for
black box testing. In the test case generation method presented in this paper, we define
classes as disjoint sets of input values of single variables and do away with the concept
of classification as our starting point is already a formal specification with well defined
input variables, rather than an informal specification. As a result, the concept of a class
vector is slightly simplified as compared to the one defined in [6].
On the other hand, the derivation of legitimate class vectors still relies on the inde-
pendence and coexistence conditions which are now more rigorously defined in terms
of the B Abstract Machine Notation (AMN) semantics. Note that for the lack of space
and the sake of clarity the definitions cover only the invariant part and operation pre-
conditions of the B specification and they can be extended to cover other specification
clauses such as CONSTRAINTS and ASSERTIONS.
75