0% found this document useful (0 votes)
4 views16 pages

Domain Testing and Error Detection

Domain testing involves analyzing the input domain and program paths to identify computation and domain errors in a program. Computation errors occur when the correct path is executed but produces incorrect output, while domain errors happen when an incorrect path is taken due to faulty conditional statements. The document outlines methods for detecting domain errors through test data selection and the identification of domains from program predicates.

Uploaded by

jeni
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views16 pages

Domain Testing and Error Detection

Domain testing involves analyzing the input domain and program paths to identify computation and domain errors in a program. Computation errors occur when the correct path is executed but produces incorrect output, while domain errors happen when an incorrect path is taken due to faulty conditional statements. The document outlines methods for detecting domain errors through test data selection and the identification of domains from program predicates.

Uploaded by

jeni
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Domain Testing

Two fundamental elements of a


computer program are input domain
and program
paths.
The input domain of a program is the
set of all input data to the program.
A program path is a sequence of
instructions from the start of the
program to some point of interest in
the program.
For example, the end of the program is
a point of interest.
Another point of interest is when the
program waits to receive another input
from its environment so that it can
continue its execution.
In other words, a program path, or
simply path, corresponds to some flow
of control in the program.
A path is said to be feasible if there
exists an input data which causes the
program to execute the path.
Otherwise, the path is said to be
infeasible.

identified two broad classes of errors,


namely, computation error and domain
error, by combining the concepts of
input data and program path.
The two kinds of errors have been
explained in the following.
Computation Error: A computation error
occurs when a specific input data causes
the program to execute the correct, i.e.,
desired path, but the output value is
wrong.
Note that the output value can be
wrong even if the desired path has
been executed.
This can happen due to a wrong
function being executed in an
assignment statement.
For example, consider a desired path
containing the statement result = f(a,
b), where a and b are input values.
A computation error may occur if the
statement is replaced by a faulty one,
such as result = f(b, a).
Therefore, the result of executing the
path can be erroneous because of a
fault in the assignment statement, and
this can happen in spite of executing a
correct path.

Domain Error: A domain error occurs


when a specific input data causes the
program to execute a wrong, that is,
undesired, path in the program.
An incorrect path can be selected by a
program if there is a fault in one or
more of the conditional statements in
the program.
Let us consider a conditional
statement of the form if (p) then f1()
else f2().
If there is a fault in the formulation of
the predicate p, then the wrong
function call is invoked, thereby
causing an incorrect path to be
executed.

The above two kinds of program errors


lead us to view a computer program as
performing an abstract mapping
function as follows.
Ideally, for each input value, the
program assigns a program path to
execute; the same program path can
be exclusively assigned (i.e.,
executed) for a subset of the input
values. Here, the subset of the input
values causing the same path to be
executed is referred to an input
domain or subdomain.
Thus, the program is said to map a
domain to a path within itself.
Since there are a large number of
values in the input domain of the
program and there are a large number
of paths in a program, we can view a
program as partitioning the input space
into a finite number of subdomains and
assigning a distinct program path to
each of the input subdomains.

We further explain the concept of


program domains using Figure 6.1.
The set D is the entire input set of a
program P (Figure 6.1a). We call D the
domain of the entire program.
Set D can be an infinite set, and P may
not have different computation
behavior for each element of D.
Instead, P may perform the same
computation for all the elements in a
certain subset of D.
For example, as shown in Figure 6.1b,
P performs five different computations,
one for each subset D 1 , . . . , D 5 .
It may be noted that the partition of D
is not visible outside P .
Instead, P has a conceptual, in-built
mechanism, as illustrated in Figure
6.1c, to decide the computation
method needed to choose a specific
branch when P is invoked with a
certain input.
Such an input classifier may not exist
in a program in a single, clearly
identifiable form. The concept can exist
as an entity as a cross-cutting concept;
it is cross-cutting because portions of
the input classifier can be found in
different program modules.
We show five different computations,
computation for D 1 through
computation for D 5 , for subsets D 1 ,
. . . , D 5 , respectively (Figure 6.1c).
The part of P that decides what
computation to invoke for a given
element of D is called an input
classifier.
Figure 6.1c simply denotes the fact
that a program does different
computations for different subsets of
its input domain.
Programs perform input classification
through sequences of predicates,
though an input classifier may not exist
as a single module.

Therefore, a program will perform the


wrong computation if there are faults in
the input classification portion.
With the above backdrop, we define
the following two terms:
A domain is a set of input values for
which the program performs the same
computation for every member of the set.
We are interested in maximal domains
such that the program performs different
computations on adjacent domains.
A program is said to have a domain
error if the program incorrectly performs
input classification.
Assuming that adjacent domains
perform different computations, a
domain error will cause the program to
produce incorrect output.

TESTING FOR DOMAIN


ERRORS
There is a fundamental difference
between flow graph–based testing
techniques and domain testing.
By flow graph we mean control flow
graph and data flow graph.
The difference is explained as follows:
Select paths from a control flow graph
or a data flow graph to satisfy certain
coverage criteria. The control flow
coverage criteria are statement
coverage, branch coverage, and
predicate coverage.
Similarly, the criteria studied to cover the
definition and use aspects of variables in
a program are all-defs, all-c-uses, all-p-
uses, and all-uses, to name a few. The
path predicates were analyzed to derive
test data. While selecting paths and the
corresponding test data, no assumption
is made regarding the actual type of
faults that the selected test cases
could potentially uncover, that is, no
specific types of faults are explicitly
considered for detection.

Domain testing takes an entirely new


approach to fault detection. One
defines a category of faults, called
domain errors, and selects test data to
detect those faults. If a program has
domain errors, those will be revealed
by the test cases.
We discuss the following concepts in
detail:
• Sources of Domains: By means of an
example program, we explain how
program predicates behave as an input
classifier.
• Types of Domain Errors: We explain
how minor modifications to program
predicates, which can be interpreted as
programming defects, can lead to domain
errors.
• Selecting Test Data to Reveal Domain
Errors: A test selection criterion is
explained to pick input values. The test
data so chosen reveal the specific kinds
of domain errors.

SOURCES OF DOMAINS
Domains can be identified from both
specifications and programs.
We explain a method to identify
domains from source code using the
following steps:
•Draw a control flow graph from the
given source code.
•Find all possible interpretations of the
predicates. In other words, express the
predicates solely in terms of the input
vector and, possibly, a vector of
constants. The reader may note that a
predicate in a program may have
multiple interpretations, because
control may arrive at a predicate node
via different paths.
• Analyze the interpreted predicates to
identify domains.

In the following, we explain the above


procedure to identify domains.
We show an example C function in
Figure 6.2 to illustrate a procedure to
identify domains.
The function accepts two inputs x and
y and returns an integer.
A control flow graph representation of
codedomain() is shown in Figure 6.3.
The two predicatesin the two if()
statements have been represented by
nodes 3 and 6 in Figure 6.3.
The predicate c> 5 in the first if()
statement has just one interpretation,
namely,
P 1 : x + y> 5
because program control reaches the
if() statement via only one path from
the initial node. However, predicate
P2:d≥c+2
in the second if() statement gets two
interpretations, because program
control can reach the second if()
statement along two paths: (i) when
the first if() evaluates to true and
(ii) when the first if() evaluates to false.
These two interpretations are
summarized in Table 6.1.

We explain a procedure to obtain


domains from the interpretations of P 1
and
P 2 (Figure 6.3).
We show a two-dimensional grid
labeled x and y in Figure 6.4.
The grid size is large enough to show
all the domains of the program under
consideration.
We consider the predicate nodes of
the control flow graph one by one
(Figure 6.3).
Predicate P 1 divides the grid into two
regions.
The P 1 boundary is shown by a
straight line represented by the
equality x + y = 5.
All the points above, but excluding this
line, satisfy predicate P 1 .
Next, we consider the two
interpretations of predicate P 2 . For P
1 = True, P2 has the following
interpretation
P 2 : x ≤ −4

Therefore, P2 further divides the area,


or set of points, defined by P1 = True
into two sets corresponding to its two
truth values.
The P2 boundary, when P1 evaluates
to true, is represented by the straight
line x = − 4.
The area to the left of the P2 boundary
and above the P1 boundary
corresponds to P1 P2 = TT, and the
area to the right of the P2 boundary
and above the P1 boundary
corresponds to P1 P2 = TF.
For P1 = False, P2 has the following
interpretation:
P 2 : x ≤ −4

Therefore, P2 further divides the area,


or set of points, defined by P1 = True
into two sets corresponding to its two
truth values.
The P2 boundary, when P1 evaluates
to true, is represented by the straight
line x = − 4.
The area to the left of the P2 boundary
and above the P1 boundary
corresponds to P1 P2 = TT, and
the area to the right of the P2
boundary and above the P1 boundary
corresponds
to P1 P2 = TF.
For P1 = False, P2 has the following
interpretation:
P 2 : x> 4
In other words, P 2 further divides the
area, or set of points, defined by P 1 =
False into two sets corresponding to its
two truth values. The P 2 boundary,
when P 1 evaluates to false, is
represented by the straight line x = 4.
The area to the right of the P 2
boundary and below the P1 boundary
corresponds to P1 P2 = FT, and the
area to the left of the P2 boundary and
below the P1 boundary corresponds to
P1 P2 = FF in Figure 6.4.

If a program contains k predicates in a


sequence, the maximum number of
domains obtained is 2k .
In practice, the number of domains
obtained is much smaller than 2k,
because certain combinations of truth
values of those k predicates may not hold
simultaneously.

TYPES OF DOMAIN ERRORS

You might also like