You are on page 1of 10

Test Case Design Based on Z and the Classification-Tree Method*

Harbhajan Singh, Mirko Conrad, Sadegh Sadeghipour


Daimler-Benz AG, Systems Technology Research (F3S/K)
Alt-Moabit 96a, D- 10559 Berlin, Germany
e-mail: { singh Iconradlsadegh} @DBresearch-berlin.de

Abstract for software. Therefore, a cost-effective test process is de-


cisive in industrial competition.
Software testing often consumes up to 50 percent of the A systematic test of a test object on the basis of its spec-
overall software costs. A large amount of time and money ification (black-box test) starts with the design of relevant
within the test process is spent due to incomplete, inconsis- test cases. A test case describes a certain input situation
tent or ambiguos informal specijications of the test objects. to be tested by comprising a set of input data. That is, it
A more formal approach to the early phases of software de- abstracts from concrete test data and defines them, only in
velopment can reduce the error rate drastically and, in ad- so far as it is required for the intended test. During test
dition, can signijicantly improve the central testing activi- data generation concrete test data are defined for the test
ties like test case design and test evaluation. cases. Determining the expected results for these test data
This paper presents an approach for generating test constitutes expected results prediction. Output values are
cases from formal specijications written in Z by combin- determined by running the test object with the test data dur-
ing the classijication-tree method f o r partition testing with ing test execution. Test evaluation eventually comprises the
the disjunctive normal form approach. Firstly, a classijica- comparison between actual and expected values [6].
tion tree describing high level test cases is constructed from Especially in the area of safety-critical systems, the use
the formal specijication of the test object. Then the high of formal methods for the development of software is highly
level test cases are further rejined by generating a disjunc- recommended by standards and legal requirements. These
tive normal form for them. The rejined test cases obtained methods promise high product confidence because the pre-
this way cover all specijied aspects of the system explicitely cision of specifications written in a formal specification lan-
and also contain all information necessary to evaluate the guage forces specifiers to express requirements and design
test results. The proposed combination of the classijication- decisions in a clear and unambiguos manner. However, a
tree method with the disjunctive normalform approach pre- post-developmental validation through testing is indispens-
serves advantages of both methods, overcomes most of their able, and the use of formal methods can improve the soft-
limitations, and can be supported by tools. ware test. The formal specification of the test object forms
the basis for a systematic design of test cases, test data gen-
eration, and test evaluation. Since it contains all the infor-
1. Introduction mation necessary for the central test activities, these steps
can be highly automated.
An objective of software testing is to find errors in the Observing that the test process can profit by using formal
test object by executing it with selected test data. Test- specifications and that test case design is the most important
ing is the primary method through which the producer of prerequisite for a thorough software test, there have been
software and the user or customer gain confidence that the quite a few attempts [ 1, 12, 171 in the recent past to gener-
software will work as intended or specified. A thorough ate test cases on the basis of formal specifications written
test which does not find errors can provide increased justifi- in the specification language Z. The methods used in these
cation for confidence in the correctness of the test object papers are based on partition testing [15]. Some authors
[6, 81. Testing, especially in projects concerning safety- [9] have compared this method with random testing and
critical systems, consumes up to 50% of the overall costs doubted its usefulness. Based on a quantitative model for
computing the fault detection probability of a given strat-
*This work was partially supported by the German Federal Ministry
of Educauon, Science, Research and Technology (ESPRESS project 01 IS egy, they have shown that partition testing is not worse than
509 A) random testing, provided some conditions concerning the

81
0-8186-8002-4/97 $10.00 0 1997 IEEE
structure of the partitioning are fulfilled. This would not and complete classifications are formed. Classes resulting
justify the overhead of partitioning and of keeping track of from these classifications may be further classified itera-
which subdomains have been tested or not. However, fur- tively. The stepwise partition of the input domain by means
ther analyses of the relationship between partition and ran- of classifications is represented graphically in the form of
dom testing have shown that partition testing can be much a tree. Subsequently, test cases are formed by combining
better than random testing, again according to the quanti- classes of different classifications. This is done by using
tative model mentioned above, if the subdomain definitions the tree as the head of a combination table in which test
are fault-based [20, 21. This means that the effectiveness of cases are selected appropriately.
a particular partition testing strategy depends on how well The use of the classification-tree method will be ex-
that strategy groups together the failure-causing inputs. We plained by giving an example. The test object is a simpli-
believe that regardless of any quantitative model for confi- fied part of the discrete control logic of a speed and distance
dence in the software, a solid basis for such a confidence can control system (SpeDi) for individual vehicles. SpeDi is an
only be provided if all the requirements have been checked adaptive cruise control system which supports the driver of
systematically. This cannot be achieved by random testing the controlled car by maintaining the desired speed of the
or a pure fault-based partitioning. Furthermore, a test strat- controlled car and a safe distance between the controlled
egy based on random testing only could be catastrophic for and a preceding car [ 141.
safety-critical systems because there is no guarantee that the
input data relevant for safety-critical aspects are actually se-
lected. This point is also true for a test which is only based
on failure-causing inputs.
Concerning the above considerations, we took partition
testing as the basis of our approach to the systematic de-
termination and description of test cases for a test object
based on its formal specification written in Z. Any imple-
mented operation, whose specification is given by a Z op-
eration schema, can be considered to be a test object. The
approach uses the classification-tree method (CTM) [6] and Figure 1. Speed and distance control system
the idea of partitioning the input domain by using a trans- (SpeDi): Fanning the road (left) and cruise
formation into a disjunctive normal form (DNF) [5,4]. control switch.(right)
The following section describes the original approaches,
the classification-tree method, and the disjunctive normal
The road in front of the vehicle is fanned by infrared
form approach, and motivates their combination. In sec-
beams in search of vehicles ahead as shown in Figure 1. As
tion 3, the chosen concept for test case design is explained
long as no vehicle is detected, SpeDi provides an ordinary
and applied to this example on the basis of its Z specifi-
speed control function, i.e. driving at the speed set by the
cation. The main steps of this concept are summarized in
driver. If a vehicle is detected in front, the system automat-
section 3.1. Section 4 characterizes the envisaged tool sup-
ically switches to the distance control mode. It forces the
port based on the existing classification-tree editor (CTE).
controlled vehicle to drive at the same speed as the preced-
Finally, section 5 summarizes the report and gives an out-
ing vehicle at a safe distance. As long as the distance be-
look to future work.
tween the two vehicles is uncritical, the behaviour of SpeDi
in the distance control mode is the same as in the speed con-
2. Combining the Classification-Tree Method trol mode. SpeDi is controlled by the cruise control switch
with the DNF Approach (Figure 1) located near the steering wheel. The driver can
define the current speed as the desired speed either through
2.1. The Classification-Tree Method the Set+ or Ser- command. With each subsequent use of
Set+ or Set-, the desired speed is incremented or decre-
The classification-tree method [6] is a special approach mented, respectively, by a fixed amount. Off switches the
to (black-box) partition testing partly by using and improv- system off, and Resume retrieves the last desired speed.
ing ideas from the category-partition method [15]. It has A possible classification tree for generating test cases on
been used successfully in various application fields of the the basis of this informal specification is shown in Figure 2.
Daimler-Benz Group. In the classification-tree method, the The root of this tree is the complete input domain of the
input domain of a test object is analysed on the basis of its control software corresponding to the above specification.
functional specification with respect to various aspects con- The possible inputs for this software are data regarding a
sidered to be relevant for the test. For each aspect, disjoint vehicle in front and the control switch. Appropriate classi-

82
fication aspects in this case are, for example, the position of Si may look like this:
SI = [Signarure I Pil A Pi2 A . . . A Pi,].
h

the control switch and the presence of a vehicle ahead. The


classification based on the aspect “control switch?’ leads The splitting of the original specification schema into its
to a partition of the input domain into sub-domains where disjunctive normal form can be carried out by transforming
this switch has one of the positions Set+, Set-, Resume, or its predicates by using a suitable rewriting system as des-
Of. The classification based on “vehicle in front?’ results cribed in the following.
in two classes - one with no vehicle ahead and the other The main task in the disjunctive normal form approach
with a vehicle ahead. The class with a vehicle ahead can is to choose a suitable, i.e., a terminating and confluent,
be further classified under the aspect “distance between two rewriting system for performing required transformations
vehicles critical?’. automatically. In such a rewriting system [4], the follow-
ing three groups of rules can be distinguished:

The first group consists of rules transforming Z expres-


sions, which are not in the syntax of regular predicate
logic, into formulas in regular predicate logic, e.g.:
E = if P then F1 else Fz t
( P A E = F1) V ( - P A E = F z ) .

The second group consists of rules distributing quanti-


yes no fiers with respect to logical connectors, e.g.:
Test case V x : A P A Q k (Vx : A P ) A ( V x : A a Q),
1
-(Vx:A.P) t 3x:A.-P.
2
3 Applying these rules to a schema predicate leads to
4
formulas which can be handled in propositional logic.
Figure 2. A classification tree for SpeDi T h i s means that each quantified formula can be con-
sidered to be a proposition.
In the combination table associated with the classifica- The rules in the third group of the rewriting system
tion tree, each row represents a test case. Some possible transform propositional logic formulas into a disjunc-
test cases are shown as examples. The first test case (rep- tive normal form. Such rules are, e.g.:
resented by the first row of the combination table), for in- P+Q b ~ P V ( P A Q ) ,
stance, describes the test in which a vehicle is in front of the P- Q k (PAQ)V(-PA-Q),
controlled vehicle, the distance between the two vehicles is P A ( Q V R ) b (P A Q ) V ( P A R ) .
critical, and the control switch is in position Set+.
As a result of such transformations of the schema predi-
2.2. The D N F Approach cates, the specification schema contains disjunctions of the
conjunctions of the schema predicates. The splitting of this
The disjunctive normal form approach is widely used [5, schema into its disjunctive sub-schemas is carried out by
4, 19, 1 1, 131 for generating test cases on the basis of formal simply using a Z calculus rule, according to which predi-
specifications. A disjunctive normal form of a predicate is a cate operators can be converted into schema operators. The
disjunction of the conjunctions of the different components schema S, for example,
of the predicate. In the following, the disjunctive normal S [SigiznfureI ( P I V Pz V . . . V P, V . . . V fn)A Rest]
form approach will be illustrated when it is applied to Z can be split as S e SI V Sa V . . . V SI V . . . V S,,, where
specifications. Thereby, it will be assumed that the reader S, [Signature 1 P , A Rest]. Here each SI represents a
is familiar with the Z notation and its usual conventions for DNF test case.
the specification of sequential systems [ 161.
Let S denote the operational specification schema of the 2.3. Discussion
test object which is the basis for the test case design. The
basic idea is to split S into a smaller set of sub-schemas The classification-tree method is well suited for tool sup-
(SI, S 2 : .. .) whose disjunction is equivalent to the original port since it decomposes the test case design process into
schema: several steps which can be supported individually, allowing
s 2 s , v s 2 v ... v s , v ... VS,. the tool to guide the user appropriately. It offers a natu-
These individual sub-schemas are the different test cases in ral way of using semantic information during test case de-
this approach. Each such test case may contain a number of sign through a suitable choice of classification aspects and
medicates which are coniugated. For examole. the test case classes. Furthermore, it makes use of a graphical notation

83
which is well suited for visualization in a modem graphical problem, the disjointedness of the generated test cases
user interface. It can, however, happen that the test cases must be achieved. This is done by extending the rewri-
obtained with the classification-tree method are not detailed ting system for a DNF to generate a canonical disjunc-
enough for the uniformity hypothesis [3] to be applicable'. tive normal form. The idea [4] is based on the natural
This can happen if some classification aspects are hidden partitioning of the union of two arbitrary sets:
at the first sight of the specification. It is especially im- A U B = (A f l B ) U ( A f l B )U ( A f l B ) ,
portant to unfold all classification aspects of fault-causing whose syntactical counterpart in propositional logic is
inputs. Such aspects become apparent when one test case at the following rule:
the classification tree level results in multiple test cases af- PV Q b ( P A Q) V (7 P A Q) V ( P A 7 Q),
ter transformation in a disjunctive normal form. Therefore, The or connector (V) on the right side of this rule is, in
some aspects or parts of the software can remain untested fact, an exclusive or operator. It can be seen easily that
with test cases from the classification-tree method. More- if a schema is a disjunction of m conjunctions, then
over, these test cases do not necessarily contain information the application of the above rule results in a canonical
for evaluating the test results. DNF with '2" - 1 conjunctions. Therefore, to reduce
A significant advantage of the DNF approach is that it a combinational explosion, all possibilities for reduc-
is purely syntax based and, therefore, can be automated in ing m (e.g., through simplification of terms, through
a straightforward way for formal specifications. The test recognition and discarding of inconsistent predicates)
cases obtained cover all the specified aspects of the software should be exploited before the application of this rule.
explicitly. Furthermore, these test cases contain all the in-
formation available from the formal specification about the Unstructured test cases: The test cases in the DNF (as
input as well as the output of the test object. On the other well as in the canonical DNF) approach are completely
hand, this approach as such has important shortcomings. In unstructured [ 171 as they all are generated at the same
the following, we discuss these shortcomings and suggest level. There is no schematic graphical representation
means to overcome them. to guide the user with respect to the relation between
the test cases and the corresponding input domain. We
e Inconsistent test cases: A test case is inconsistent if propose to overcome this shortcoming by combining
at least two of its predicates have a common variable the canonical DNF approach with the classification-
and the set containing the solution elements for these tree method (see section 2.4).
predicates is empty. Many inconsistent test cases are
generated during the process of generating a disjunc- In the following, the canonical disjunctive normal form ap-
tive normal form - even if the original schema is free proach will be used, i.e., hereafter DNF stands for canoni-
from any inconsistencies. Therefore, the generated test cal disjunctive normal form. Dick and Faivre [4] have sug-
cases must be analysed to identify inconsistent ones gested a rewriting system for transforming VDM predicates
which are then discarded. In order to identify incon- in disjunctive normal form and for simplifying them. We
sistent test cases on the basis of an empty solution set, plan to adapt their system for Z specifications and to im-
all possible inputs must be tried. As this problem is prove it by introducing relevant rules for making it more
not decidable, some simple heuristics and rules can be powerful in recognizing inconsistent test cases.
used to obtain a solution [13]. A family of rules in
this connection are rules expressing special syntactical 2.4. Combination
and semantic knowledge leading to the simplification
of the generated formulas. Such simplification can re- The major shortcoming of the disjunctive normal form
sult in recognizing the inconsistent test cases automati- approach lies in its completely unstructured test cases. This
cally. A rule of this category is, e.g.: P A ( P V Q)t- P . is shown schematically on the left side of Figure 3 where the
outermost rectangle represents the semantics of the whole
e Semantically indisjoint test cases: The test cases gen- schema under consideration, and each small square within
erated by using the rewriting system described in sec- this rectangle represents a different test case in the DNF ap-
tion 2.2 are in general not semantically disjoint. This proach. These test cases are all at the same (the lowest) level
can lead to the fact that the test data derived from dif- of complexity and cannot be refined further. Moreover, the
ferent test cases only test a common portion of the in- number of generated test cases quickly becomes very large
put domain for these test cases and that the remain- so that the whole process gets complicated for a user. Es-
ing input domain remains untested. To overcome this pecially, there is no guidance to find the relevant test cases
'According to the uniformity hypothesis, if a test object passes the test
for a particular input domain, the input domains not tested
for one value of the sub-domain, it passes the test for all the values of the so far, and whether or not a particular (for instance safety-
sub-domain. critical) input domain has been thoroughly tested.

84
I rU 6mt IewI At m d 1-
cannot be further refined).

3. Test Case Design Based on Z Specifications


PI P2 qf qz q3
I 1 I In this section, our concept for the test case design is
sA(P *PI) - described at first. This concept is then applied to generate
test cases for a part of the adaptive cruise control system
Figure 3. Classification of DNF test cases (see section 2.1) on the basis of its specification written in
Z.

These shortcomings can be overcome by combining the 3.1. Concept


disjunctive normal form approach with the classification-
tree method. The key point is to establish a direct link be- A central point of our concept for the test case design
tween the input domain and the DNF test cases by overlay- on the basis of Z specifications is the combination of the
ing the DNF partitions with a hierarchical partition of the classification-tree method and the disjunctive normal form
input domain. The criteria for a hierarchical classification approach. Furthermore, a maximum use of the automation
of the input domain should be important semantic charac- potential offered by Z specifications is envisaged: Firstly,
teristics of the schema variables. Such characteristics are a concept is presented for constructing a classification
used as the classification aspects in the classification-tree tree semi-automatically. Secondly, it is shown, how to
method. In Z schemas, characteristics of the schema vari- get Z specifications of high level test cases automatically
ables are expressed through their predicates. from such classification trees. Thirdly, a method based on
For example, let a specification of a test object be char- the contents of section 2.4 is outlined for combining the
acterized by a Z schema S whose predicate part is P V Q, disjunctive normal form approach with the classification-
where P and Q represent disjoint sets. Furthermore, assume tree method. The main steps for the test case design are
that P = p l V p2 and Q = ql V 92 V 93 where each sub- summarized at the end.
predicate can be further split into lower level sub-predicates
until the resulting sub-predicates are atomic. The DNF test Classification-tree construction. Any implemented
cases for this schema are represented by dotted squares in operation, whose specification is given by a Z operation
Figure 3 on the left. The outermost rectangle representing schema, can be considered to be a test object. The input
schema S also represents the whole input domain of the test domain of the Z operation schema is analysed according
object. A classification of this input domain into two sub- to the different classification aspects for partitioning this
domains at the first level of hierarchy is described by the domain. The basis of such classification aspects are
predicates P and Q in Figure 3 on the left. Each of these test-relevant properties of the schema variables. These
sub-domains can be further partitioned at the second level properties are expressed in the schema signatures and
of hierarchy through the predicates p l , p2 and q l , q2, q3, schema predicates. For example, if a schema contains a
respectively. predicate P. a classification aspect is whether P is true
The classification tree offers a clear, graphical and hier- or false. Accordingly, the corresponding classes for this
archical structure for such a partition of the input domain classification are P and P. With complex predicates, such
7

whereby the basis of the classifications are the predicates in classifications can be carried out iteratively. Therefore,
Z, as shown in Figure 3 on the right. The original schema different classification aspects and their classes can be
together with the constraining predicates of a selected test determined automatically by using syntactical and semantic
case can be finally transformed into a disjunctive normal information about the schema variables. The syntactical
form as discussed in the two technical possibilities below. information is fully contained in the formal specification.
The correspondance between the test case S A ( Q A 42) For the semantic information, for instance, on standard data
and its DNF test cases is indicated by an arrow in the mid- types, an appropriate knowledge base can be used.
dle of Figure 3. In contrast to the test cases in the original A formal specification can lead to classification trees
classification-tree method, the test cases obtained here are with different structures depending on
refined and contain information, i.e. predicates over state 0 the order in which different classification aspects are
and output variables, for evaluating the test results. In the considered, and
following, the test cases generated with the classification-
tree method alone are called high level test cases; test cases 0 the nodes, the resulting classifications are attached to.
generated by using the DNF approach are, accordingly, This determines, for example, if the generated tree
called rejned test cases (or atomic test cases because they grows more in width or in depth.

85
The structure of a classification tree has a decisive effect through a systematic combination of leaf classes by using
on the quality and the number of the generated test cases. a graphical combination table. The test cases can be
Moreover, the number of inconsistent test cases may be specified either by the user or automatically. The aim is
much larger in a classification tree with one structure as to have maximum coverage of the functionality of the test
compared to the other. Consequently, well-considered de- object with a minimum possible number of test cases. An
cisions must be taken with respect to both the points listed automatic selection can be based on different strategies
above. For that, first of all, all the test-relevant semantic such as selecting each class at least once or selecting all
knowledge about the specification is required. Furthermore, logically possible combinations of classes of different
some general heuristics xv and strategies are needed for us- classifications. The first strategy, for example, can be
ing this knowledge to generate an appropriate classification supplemented through an intensive selection of those
tree for the given specification. Until such a knowledge base classes which are related to safety-critical aspects in the
and heuristics/strategies are developed, this role can be per- software. An automatic selection of the test cases should
formed by the user, who is generally well informed about be regarded as a proposal for the user who can change the
the specification. selected test cases according to his choice.
The classification tree obtained on the basis of a for-
mal specification is entirely formal since the individual
classes are characterized by formal predicates. Therefore,
the formal descriptions of the selected test cases can
be automatically generated in a straightforward way by
conjugating the predicates of the selected classes (see
section 3.2). During this process, it should be possible to
recognize most of the inconsistent test cases automatically
through an appropriate simplification mechanism.

Classification Tree Generation of refined test cases. In the classification-tree


method, the power of the strategies used and the skills of
the tester determine whether or not all the possible classifi-
Figure 4. Concept for a semi-automatic gen-
cation aspects have been identified and appropriately used.
eration of a classification tree
Consequently, the high level test cases generated by using
this method may not be always detailed enough so that it
Our approach for a semi-automatic classification-tree could be necessary to refine them further. Moreover, they
construction is depicted in Figure 4. The source for syn- may not contain any information about the output variables
tactical information is the formal specification of the test and the (input or state) variables which do not appear in
object, and a source for semantic information is an appro- the classes considered. Such information is needed for
priate knowledge base. The user can supplement both of a complete specification of the input state and for the
these pieces of information. Furthermore, some general evaluation of the test results. These shortcomings can be
strategies and heuristics are required to generate meaning- overcome automatically by supplementing each selected
ful classification trees. Based on all this information, the test case with the original schema of the test object since
system would generate a classification tree which could be this schema contains all the information about the test
modified by a user. object.
For software validation, it is often important to test To illustrate this, let the classes selected for a test case in
certain situations which are not explicitly taken into the classification-tree method be characterized by the pred-
account in the original specification. Our concept also icates p and q. Then the corresponding high level test case
allows the consideration of such validation tests during is characterized by the predicate p A q. The corresponding
the test generation phase. The user can define arbitrary complete specification schema for this test case is given by
test-relevant classification aspects and the corresponding Testcase E spec A [Signature I p A q],
classes in the classification tree under consideration. In where Signature is the signature of the specification schema
order to be integrated with the rest of the classes, these Spec for the test object. The resulting schema TestCase
classes must also be formally defined through predicates in is then transformed into the disjunctive normal form to
Z. get fully refined test cases. The process of generating re-
fined test cases from a selected high level test case in the
Specification of high level test cases. In the classification-tree method, therefore, involves the following
classisification-tree method [6], test cases are defined steps:

86
0 Conjugate the specification schema of the test object cases. These test cases also contain information for
with the predicates characterizing the selected high the evaluation of the test results.
level test case and simplify the resulting schema to get
As a Z specification contains most of the information re-
the complete schema for the selected test case.
quired for the above activities in a formal way, all these ac-
0 Transform the test case schema into (canonical) dis- tivities can be automated to a large extent.
junctive normal form to get refined test cases which
also contain information for the evaluation of test re- 3.2. Application to an Adaptive Cruise
sults. Control System

To carry out these steps efficiently, powerful strategies and To illustrate our concept for designing test cases on the
rewriting rules are required (as discussed in section 2.2 basis of Z specifications, relevant parts of the adaptive
and 2.3). Otherwise, the number of refined test cases soon cruise control system SpeDi are formalized first in Z.
becomes very large. At each step, full potential for the Then a classification tree is constructed (steps 1 to 4 in
section 3.1) on the basis of this specification and a high
simplification of the resulting schemata, especially with level test case is selected (step 6). Finally, refined test cases
respect to recognizing the inconsistent test cases, should be are generated (steps 7 and 8) for this test case.
used.
Formal specification of SpeDi in Z. The behaviour
of the SpeDi controller depends on the value of the control
Main steps for test case design. Summarizing our switch, the speed of the controlled car, whether or not a
concept for test case design for a test object on the basis of vehicle is detected in front of the controlled car, and the
an operation schema in Z, as described above, leads to the internal state of SpeDi. To concentrate on the illustration
of our concept of test case design, only a part of the control
following main steps: logic is formalized, and the internal state of SpeDi is
neglected. The four positions of the control switch are
1. Identify the test-relevant variables for the test object on modelled by a free type [ 161
the basis of the signature of its specification schema. Switch ::= Set+ 1 Set- 1 Resume I Of.
For safety reasons the SpeDi controller is not allowed to be
2 . Design classification aspects for these variables on the active if the speed of the controlled car is less than 40
basis of their signatures and characterizing predicates
in the schema.
or higher than 160 9.
This is described by defining the
admissible speed for the SpeDi controller as:
3. Generate classes for each classification aspect as con-
AdmissibleSpeed == { v : Speed I 40 p 5 v 5 160 }.
The speed and distance controllers are considered to be
crete instances of the predicate used for designing the black boxes and are represented only by the signatures of
corresponding classification aspect. their respective transfer functions SC and DC:
SC : Speed x opt Speed + Acceleration
4. As a class can be partitioned further with respect to a DC : Speed x opt Speed x apt BeamData +Acceleration
new classification aspect, repeat steps 2 to 3 iteratively
The speed controller can be viewed as a function which cal-
until the classifications of the important and relevant
culates the required acceleration from the actual speed of
variables are treated to the desired level of refinement.
the controlled car and the speed desired by its driver. Since
5. If necessary, supplement the classification tree ob- the desired speed is not always defined, it is modelled by
tained with classification aspects and classes, whose an optional data type optSpeed2. The distance controller
predicates are not contained in the specification becomes active when a vehicle is detected in front of the
schema of the test object. controlled car (expressed by the schema VehicleInFront in
schema SpeDiControl below) by the infrared beams. The
6. Select appropriate (high level) test cases in the combi- corresponding function calculates the required acceleration
nation table of the classification tree by selecting at the by giving additional consideration to the optional data (de-
most one class out of each classification. scribed by the schema BeamData in schema SpeDiControl
below) about the detected vehicle. No further information
7. Conjugate the specification schema with the predicates
about VehicleInFront and BeamData is required. Based on
characterizing the selected high level test case and sim-
these definitions, the main behaviour of the SpeDi control
plify the resulting schema to get the complete schema
logic can be modelled by using three simple rules:
for the selected test case. Discard the test case if it is
found to be inconsistent (section 2.3).
0 If the speed of the controlled car is not admissible, nei-
8. Transform the consistent test case schema into the ther the speed nor the distance controller provide any
canonical disjunctive normal form to get refined test * A variable of this optional type can have a defined value (any possible
cases and analyse them to remove inconsistent test speed) or can be undefined.

a7
value for the required acceleration, i.e., the optional the formal specification, this classification tree can be gen-
output areq!is not defined. erated semi-automatically. However, the user can modify
this tree, for example, by defining validation-relevant clas-
If the speed of the controlled car is admissible, if no sification aspects which are not explicitly contained in the
vehicle is detected in front, and if the speed is set by formal specification, e.g. the weather situation in the speci-
the driver through the control switch, SpeDi is in the fication of SpeDi. Such classification aspects and the corre-
speed control mode, i.e., aR4!is defined and its actual sponding formal classes could be inserted manually at any
value is determined by SC (def areq!as SC(v,,,: vdex)). desired position in the classification tree of Figure 5 and
would automatically be taken into account for further con-
If the speed of the controlled car is admissible, if a siderations.
preceding vehicle is detected, and if the speed is set,
SpeDi calculates the required acceleration by switch- The high level test cases in the classification-tree method
can be selected by using different strategies (see sec-
ing into the distance control mode, i.e., areq!is defined tion 3.1). The formal description of the selected test cases
and its actual value is determined by DC. can be automatically generated in a straightforward way
by conjugating the predicates of the selected classes. For
example, Testcase4 in Figure 5 is characterized by the
These rules can be formally described by the following predicate v,,, E AdmissibleSpeed A -- VehiclelnFront.
Z schema where the three predicates formally specify the This test case neither contains information about the input
three rules for the SpeDi control logic described above: variable ControlSwitch? nor about the output variable areq!.
SpeDiControl Furthermore, it is possible to partition this test case into
vcor : Speed more detailed test cases as shown in the next section.
vder : opt Speed
Vehicle : opt BeamData Refined test cases for TestCase4. In this section, it
ControlSwitch'? : Switch is shown how to automatically generate refined test cases
amy! : opt Acceleration corresponding to the high level test case TestCase4 (see
Figure 5).The complete specification schema for TestCuse4
is obtained by conjugating its characterizing predicate with
(wcor E AdmissibleSpeed A 7 VehiclelnFront A the original schema of the test object, i.e.,
(ControlSwitch? = Set+ V ControlSwitch'?= Set-) + Testcase4 SpeDiControl A [Signature
defarey!as SC(vcnr,v~/e.v)) I v,,, E AdmissibleSpeed A 7 VehiclelnFront].
(vCnrE AdmissibleSpeed A VehiclelnFront A where Signature is the signature of SpeDiControl. This
(ControlSwitch'? = Set+ V ControlSwitch? = Set-),+ schema can be simplified to the schema:
def arey!as DC(v,,,; v , / ~ ,Vehicle))
~: -TestCase4
Signature

A classification tree on the basis of SpeDiControl. vCRrE AdmissibleSpeed A -, VehiclelnFront


((ControlSwitch'?= Set+ V ControlSwitch'? = Set- V
The test-relevant schema parameters in the schema ControlSwitch'? = Resume j ) d e f a,q! as SC(v,,,. " d e i ) )
SpeDiControl are vCur.VehicleInFront and ControlSwitch?.
Their properties are expressed by formal predicates which Applying transformation rules for implication and for gen-
erating a canonical disjunctive normal form, this schema
are used to generate different classifications. The classi- can be transformed into the following form:
fication tree obtained is shown in Figure 5. The differ-
ent classes of a classification aspect are different predicates
which specify the given classification aspect in disjoint sit-
(vcor E AdmissibleSpeed A 7 VehiclelnFront A
uations. As most of the information required is contained in ControlSwitch'? = Set+ A def areq!asSC(v,,, v<les))
V
(vcor E AdmissibleSpeed A 7 VehiclelnFronr A
ControlSwifch'? = Set- A def amy!asSC(v,,. w~/<~))

VI., e
Admiisiblespeed
- VI.. E
V
(vcorE AdmissibleSpeed A VehiclelnFront A
7

ConrrolSwifch? = Resume A d e f arey!as SC(vcur.v,ler))


Vehic!dnFmni ? V
(vCorE AdmissibleSpeed A 7 VehiclelnFront A
Testcase 1 TRUE
I
FALSE
1
I
1 I I
ControlSwitch? # Set+ A ControlSwitch'? # Set- A
1 I I I I I
ControlSwitch? # Resume A def aEq!as SC(v,,, v,/<,))
2 T 1 V
(vcor E AdmissibleSpeed A VehicleInFronr A
7

ControlSwitch'? # Set+ A ControlSwitch'? # Set- A


ControlSwitch? # Resume A 7 d e f are#!asSC(v,,. vde.<))
Figure 5. A classification tree for SpeDi on
the basis of its formal specification Each of these five disjoint components for the high
level test case Testcase4 represents a different refined

88
test case. The first three of these test cases corres-
pond to the three test cases which could be selected in
the extended combination table of the classification tree
3f Figure 5 by marking the appropriate classes, such
that the predicates 1 VehiclelnFront, ControlSwitch? =
Set+ and 7 VehiclelnFront, ControlSwitch? = Set- and
-,VehicleInFront, ControlSwitch? = Resume are valid, re-
spectively. In this way, the combination of the DNF ap-
proach with the classification-tree method takes into ac-
count the classification aspects which are not explicitly con-
sidered in the classification tree. Furthermore, the refined
test cases contain explicit information about the output vari-
able areq!which can be used for the test evaluation. The
last two refined test cases lead to different output situations
for the same input situation. This is because the behaviour
of SpeDi in schema SpediControl is not specified for the (vex E AdmissibleSpeed A -.I VehkklnFrmt A
bntrdswitcb? =Set- A def a,q!ssSC(v,. v&))
case ControlSwitch? # Set+ A ControlSwitch? # Set- A
ControlSwitch? # Resume. In this way, the analysis of re-
fined test cases can help in recognizing specification flaws
like incompleteness.
Figure 6. The main window of the envisaged
extended classification-tree editor
4. Tool Support
user should be able to define new rules for the mathematical
As described above, the classification-tree method em- objects used in the specification.
ploys a graphical representation of the classification tree
The development of CTE will proceed in two directions.
and the corresponding combination table. In order to sup-
The first direction concerns the implementation of program
port this method, a syntax-directed graphical editor, named
and user interfaces as well as other facilities to handle Z
classification-tree editor CTE 171, has been developed at
specifications [ 181, e.g.:
the Systems Technology Research Center of Daimler-Benz.
This tool enables the tester to work interactively on the tree
and the combination table. The main window in the back- 0 Interface for reading Z specifications.
ground of Figure 6 shows a typical screen image of CTE. 0 User interface for specifying Z predicates as classifica-
The upper part of the window is the area in which a classifi- tions and classes including syntax and type checking of
cation tree can be drawn interactively. The lower part of the the given formulas.
window contains a table corresponding to the tree, in which
test cases can be selected. Additional textual annotations 0 A mechanism for describing test cases in Z through
can be added to classifications, classes and test cases. The conjunction of selected classes with the Z schema of
test case design can be documented by printing out the trees the test object.
and tables.
0 Interface with the tool for transforming Z predicates
It is planned to integrate the concept of test case design into DNF.
based on Z, as described in section 3, into CTE. A sepa-
rate tool will be implemented for transforming Z schemata 0 User interface to represent refined test cases.
into a DNF and for recognizing inconsistent test cases. This
tool will accept Z schemata as input and will transform them Figure 6 shows the main window of the extended envis-
into an abstract syntax as an internal representation. It will aged classification-tree editor where the combination table
contain a rewriting system to transform Z schemata into a is overlapped by a seperate window which contains the Z
DNF and a simplifier for recognizing inconsistent test cases specifications of the refined test cases for the high level test
[lo]. The simplifier will have an interface for defining new case TestCase4 of SpeDi (see section 3.2). With the aid of
rules because the power of the simplification strongly de- this window the tester can observe, scroll and analyse the
pends on the properties of sets, functions, and other pre- refined test cases. For example, the inconsistent test cases
defined data types used in the specification. Therefore, the which have not been recognized by the simplifier could be

89
discarded. Only valid and important test cases (for example, [3] P. Dauchy, M. C. Gaudel, and B. Marre. Using algebraic
according to the safety-critical aspects) could be included in specifications in software testing: A case study on the soft-
the list of the selected test cases. ware of an automatic subway. Journal of Systems and Sofr-
ware (USA),21(3):229-244, 1993.
The second direction of the extension of CTE concems the [4] J. Dick and A. Faivre. Automating the generation and se-
semi-automatic classification-tree generation described in quencing of test cases from model-based specifications. In
section 3.1. The upper part of the window in Figure 6 J. Woodcock and P. Larsen, editors, Proceedings of Formal
contains the classification tree of SpeDi derived from its Z Methods Europe '93, volume 670 of LNCS, pages 268-284,
specification described in section 3.2. The additional menu 1993.
[SI J. S . Gourlay. A mathematical framework for the investiga-
point TreeGeneration with its sub-menus is meant to
tion of testing. IEEE Transactions on Software Engineering,
support the user by generating classifications and classes. SE-9(6):686-709, November 1983.
[6] M. Grochtmann and K. Grimm. Classification trees for par-
tition testing. Software Testing, Verificationand Reliability,
5. Summary and Outlook 3:63-82, 1993.
[7] M. Grochtmann, J. Wegner, and K. Grimm. Test case de-
sign using classification trees and the classification-tree ed-
Test case design is the most crucial activity for a trustwor- itor. In Proceedings of 8th International Quality Week, San
thy software test. As formal specifications contain most of Francisco, Paper 4-AA, 1995.
the information needed for black-box testing, we presented [8] P. A. V. Hall. Towards testing with respectto formal specifi-
a concept of automating test case design on the basis of Z cation. In 2nd IEE/BCS Con$ on Software Engineering '88,
specifications. This concept results in a method which is a 1988.
[9] D. Hamlet and R. Taylor. Partition testing does not inspire
combination of the classification-tree method and the dis- confidence. IEEE Transactions on Software Engineering,
junctive normal form approach. These two approaches are 16(12):1402-141 I , December 1990.
combined in such a way that the resulting method contains [lo] S. Helke, T. Neustupny, and T. Santen. Automating test case
the advantages of both of them and also overcomes most of generation from Z specifications with Isabelle. In Procced-
their limitations. Furthermore, some ideas for automating ings of Z Users Meeting '97, 1997.
different steps of the presented concept were outlined. [ I l l H. M. Horcher and J. Peleska. Using formal specifica-
tions to support software testing. Software Quality Journal,
The presented test case design method is based on an input- 4(4):309-328, 1995. ,

based partitioningstrategy, enabling the user to test all func- [ 121 G. Laycock. Formal specificationand testing. Software Test-
tional and safety requirements. However, at different levels ing, Verificationand Reliability, 2:7-23, 1992.
of test case design and test data generation, failure-based [ 131 K. Moritz. Automatische Testklassenerzeugung von Z-
partitioning [20,2] can and should be realized as well. The Spezifikationen (in german). Master's thesis, Christian-
user has the freedom to choose such a partitioning during Albrecht-Universitaetzu Kiel, 1994.
[ 141 G. Nocker. Abstandsregelung (in german). VDI-Berichte,
the design of high level test cases. For example, the part-
8171327-337,1990.
tioning of the domain of an integer variable into 0 and > 0 [IS] T. J . Ostrand and M. J. Balcer. The category-partitions
i s directed by the intuition of the tester that 0 might be a method for specifying and generating functional tests. Com-
failure-causing input. munications of the ACM, 31(6):676-686, June 1988.
(161 J. Spivey. The Z Notation. A Reference Manual. Prentice
The realization of the presented concept will semi-
Hall, New York, 2nd edition, 1992.
automatically lead to refined test cases in the form of small [I71 S . Stepeny. Testing as abstraction. In ProceedingsofZ Users
Z schemata for a given Z specification of the test object. Meeting '95, pages 137-151. Springer-Verlag,1995.
Based on such test cases, methods and tools for increasing [18] T. WeiB. Testfallgenerierung anf der Basis von Z-
the automation potential for test data selection and test re- Spezifikationen mit Hilfe der Kiassifikationsbaum-Methode
sults evaluation shall be developed. (in german). Master's thesis, Technische Univenitat Berlin,
Institut fur angewandte Informatik, 1997.
[ 191 E. Weyuker,T. Goradia, and A. Singh. Automatically gener-
References ating test data from a boolean specification. IEEE Transac-
tions on Software Engineering, 20(5):353-363, May 1994.
[20] E. Weyuker and B. Jeng. Analyzing partition testing
[ I ] N. Amla and P. Ammann. Using Z specifications in category strategies. IEEE Transactions on Software Engineering,
partition testing. Technical report, George Mason Univer- 17(7):703 -711, July 1991.
sity, 1992.
[2] T. Y. Chen and Y.T. Yu. On the relationship between par-
tition and random testing. IEEE Transactions on Software
Engineering, 20(12):977-980, December 1994.

90

You might also like