Chapter6 Part2
Chapter6 Part2
Ch. 6
Ch. 6
Systematic black-box
techniques
Syntax-driven testing
Decision table based testing
Cause-effect graph based testing
Ch. 6
Ch. 6
Decision-table-based testing
The word-processor may present portions of text
in three different formats: plain text (p), boldface
(b), italics (i). The following commands may be
applied to each portion of text: make text plain
(P), make boldface (B), make italics (I), emphasize
(E), super emphasize (SE). Commands are
available to dynamically set E to mean either B or
I (we denote such commands as E=B and E=I,
respectively.) Similarly, SE can be dynamically set
to mean either B (command SE=B) or I (command
SE=I), or B and I (command SE=B+I.)
Ch. 6
*
*
*
*
SE
E=B
E=I
SE = B
SE = I
SE = B + I
action
*
p
Ch. 6
b,i
b,i
O
R
P
A
N
D
E
E=B
SE
E=I
SE = B
SE = I
O
R
A
N
D
SE = B + I
Coverage criterion
Generate all possible input
combinations and check outputs
May reduce the number by going
backwards from outputs
OR node with true output:
use input combinations with only one true
input
10
Criterion
If x>y then S1; else S2; endif
After partitioning the input domain
D into several classes, test the
program using input values not only
inside the classes, but also at
their boundaries
This applies to both white-box and
black-box techniques
Ch. 6
11
Test Oracle
We must guarantee that our test is
accurate
We must verify, by running our
software on the selected test set,
that the results obtained do indeed
comply with the software goals, as
stated in the specification
Ch. 6
12
Test Oracle
Once we have selected a suitable test
set for an air traffic control system,
we should actually run the system by
applying it to real flights to verify
whether it does prevent accidents.
Ch. 6
13
Test Oracle
A test oracle determines whether a system
behaves correctly for test execution
An oracle is a mechanism used by
software testers and software engineers
for determining whether a test has passed
or failed. It is used by comparing the
output(s) of the system under test, for a
given test case input, to the outputs that
the oracle determines that product should
have.
Ch. 6
14
Reactive Systems
Check functionality
Timing
Safety
Ch. 6
15
Comparator
Compare predicted and obtained results
Evaluator
Determine whether the comparison
results are sufficient close to be a pass
Ch. 6
16
17
Ch. 6
18
Integration testing
integration of modules and subsystems
System testing
testing the entire system
Acceptance testing
performed by the customer
Ch. 6
19
Module testing
Scaffolding needed to create the
environment in which the module
should be tested
stubs
modules used by the module under test
driver
module activating the module under test
Ch. 6
20
PROCEDURE
UNDERTEST
STUB
CALL
DRIVER
CALL
ACCESSTONONLOCALVARIABLES
Ch. 6
21
Integration testing
Big-bang approach
first test individual modules in isolation
then test integrated system
Incremental approach
modules are progressively integrated
and tested
can proceed both top-down and bottom-up
according to the USES relation
Ch. 6
22
C
D
Ch. 6
Otherwise, if we proceed
top-down only stubs are
needed
23
M1
Example
M2
M2,1
M2,2
Testing OO programs
New issues
inheritance
genericity
polymorphism
dynamic binding
Ch. 6
25
Inheritance
Personnel
Consultant
Manager
Employee
Administartive_Staf
Ch. 6
Technical _Staf
26
Ch. 6
27
A sample strategy
A test that does not have to be repeated
for any heir (subclass)
A test that must be performed for heir
class X and all of its further heirs
A test that must be redone by applying
the same input data, but verifying that
the output is not (or is) changed
A test that must be modified by adding
other input parameters and verifying that
the output changes accordingly
Ch. 6
28
29
30
Analysis
Ch. 6
31
Symbolic execution
Can be viewed as a middle way
between testing and analysis
Executes the program on symbolic
values
One symbolic execution
corresponds to many actual
executions
Ch. 6
32
Example
Consider executing the following fragment
read(a); read(b);
x := a + b;
write(x);
Human analysis for the above program:
Let A and B be the first two values of the input file. They
are assigned to variables a and b, respectively. Thus, the
result of the assignment x := a + b is that x gets the value
A + B. Finally, A + B is printed.
Ch. 6
33
Ch. 6
34
Example(1)
read(a); read(b);
x := a +1; y := x *
b;
write(y);
Symbolic output:
read(a); read(b);
x:= a + 1;
x := x + b + 2;
write(x);
Symbolic output:
Ch. 6
35
Example(2)
1
x := y + 2
a := a + 2
y := x + 3
3
x := x + a + y 4
Ch. 6
36
Example(2)
When control reaches the
conditional, symbolic values do not
allow execution to select a branch
One can choose a branch, and
record the choice in a path condition
Result:
<{a = A, y = Y + 5, x = 2 * Y + A + 7},
<1, 3, 4>, Y + 2 A>
execution path condition
path
Ch. 6
37
Example(2)
When control reaches the
conditional, symbolic values do not
allow execution to select a branch
One can choose a branch, and
record the choice in a path condition
Result:
<{a = A+2, y = Y, x = 2 * Y + A + 4},
<1, 2, 4>, Y + 2 > A>
execution path condition
path
Ch. 6
38
symbolic state:
<symbolic_variable_values, execution_path, path_conditio
read (x)
Write (expression)
39
40
Ch. 6
42
43
Example
X denotes an integer array variable of length 5
1.
2.
3.
4.
5.
6.
7.
8.
9.
read( i ) ;
y := x( i );
x(3) := 9;
read( i );
x( i ) := 3 + y;
y := x( 2 );
read( i );
x( i ) := x( i ) 1;
y := y + x( i );
Ch. 6
44
Example(cont)
Let execution start in an initial state in which the
symbolic value X1 is bound to x.
1.
2.
3.
4.
5.
read( i ) ;
y := x( i );
x(3) := 9;
read( i );
x( i ) := 3 + y;
6.
7.
8.
9.
y := x( 2 );
read( i );
x( i ) := x( i ) 1;
y := y + x( i );
i = I1
y = X 1(I1)
x = X 2 where X2 = X1<3, 9>
i = I2
x = X3 where X3 = X2<I2, 3 + X1(I1)>
that is, X3(I2) = 3 + X1(I1)
y = X 3(2)
i = I3
x = X4 where X4 = X3<I3, X3(I3) 1>
y = X 3(2) + X4(I3)
Ch. 6
45
Example(cont)
The symbolic state expressed as a function of the
symbolic values read and xs initial value X1.
y = X1<3, 9><I2, 3 + X1(I1)>(2) +
X1<3, 9><I2, 3 + X1(I1)> <I3, X1<3, 9><I2, 3 +
X1(I1)>(I3) 1>(I3)
Ch. 6
46
47
Example (1)
found := false; counter := 1;
while (not found) and counter < number_of_items loop
if table (counter) = desired_element then
found := true;
end if;
counter := counter + 1;
end loop;
if found then
write ("the desired element exists in the table");
else
write ("the desired element does not exist in the table");
end if;
Ch. 6
48
Example (2)
1
2
3
found := true
6
5 counter := counter + 1
8
write "the desired
element does not
exist in the table"
9
write "the desired element exists in the table"
Ch. 6
49
Model checking
Correctness verification, in general, is
an undecidable problem
Model checking is a rather recent
verification technique based on the fact
that most interesting system properties
become decidable (i.e., algorithmically
verifiable) when the system is modeled
as a finite state machine
Ch. 6
50
Principles
Describe a given systemsoftware or
otherwiseas an FSM
Express a given property of interest as a
suitable formula
Verify whether the systems behavior does
indeed satisfy the desired property
this step can be performed automatically
the model checker either provides a proof that
the property holds or gives a counterexample in
the form of a test case that exposes the systems
failure to behave according to the property
Ch. 6
51
52
Debugging
The activity of locating and
correcting errors
It can start once a failure has been
detected
The goal is closing up the gap
between a fault and failure
memory dumps, watch points
intermediate assertions can help
Ch. 6
53