1414 Lecture 7
1414 Lecture 7
Lecture 9
INTRODUCTION
Observable
Incorrect output is easily identified; internal errors are automatically
detected
Controllable
The states and variables of the software can be controlled directly by the
tester
Decomposable
The software is built from independent modules that can be tested
independently
CHARACTERISTICS OF TESTABLE
SOFTWARE
Simple
The program should exhibit functional, structural, and code simplicity
Stable
Changes to the software during testing are infrequent and do not invalidate
existing tests
Understandable
The architectural design is well understood; documentation is available and
organized
LEVELS OF TESTING
• Unit Testing
• Integration Testing
• Validation Testing
• Acceptance Testing
UNIT TESTING
Black-box testing
Knowing the specified function that a product has been designed to perform, test to see if
that function is fully operational and error free
Not concerned with internal logical structure of the software
White-box testing
Knowing the internal workings of a product, test that all internal operations are
performed according to specifications and all internal components have been exercised
Logical paths through the software are tested
Test cases exercise specific sets of conditions and loops
13
WHITE-BOX TESTING
WHITE BOX TESTING
Test cases are derived from the internal design specification or actual
code for the program.
Advantages
Tests the internal details of the code;
Checks all paths that a program can execute.
Limitations
Wait until after designing and coding the program under test in order to select
test cases.
WHITE BOX TESTING
WHITE BOX TESTING
18
BASIS PATH TESTING
• White-box testing technique proposed by Tom McCabe enables the test case
designer to derive a logical complexity measure of a procedural design
• Uses this measure as a guide for defining a basis set of execution paths
• Test cases derived to exercise the basis set are guaranteed to execute every
statement in the program at least one time during testing
19
FLOW GRAPH NOTATION
A circle in a graph represents a node, which stands for a sequence of one or more
procedural statements
A node containing a simple conditional expression is referred to as a predicate node
Each compound condition in a conditional expression containing one or more Boolean
operators (e.g., and, or) is represented by a separate predicate node
A predicate node has two edges leading out from it (True and False)
20
FLOW GRAPH EXAMPLE
FLOW CHART FLOW GRAPH
0 0
1 1
2 2
3
3
6 4 6 4
7 8 5
7 8 5
9
9
11 10 11 10 21
INDEPENDENT PROGRAM
PATHS
Defined as a path through the program from the start node until the end node
that introduces at least one new set of processing statements or a new condition
(i.e., new nodes)
Must move along at least one edge that has not been traversed before by a
previous path
Basis set for flow graph on previous slide
Path 1: 0-1-11
Path 2: 0-1-2-3-4-5-10-1-11
Path 3: 0-1-2-3-6-8-9-10-1-11
Path 4: 0-1-2-3-6-7-9-10-1-11
The number of paths in the basis set is determined by the cyclomatic complexity
22
CYCLOMATIC COMPLEXITY
23
DERIVING THE BASIS SET AND
TEST CASES
24
CYCLOMATIC COMPLEXITY
25
CONVERTING CODE TO GRAPH
if expression1 then T F
expr1 n1
statement2 ?
else
(a) statement3 statm2 statm3 n2 n3
end if
statement4
statm4 n4
switch expr1
case 1: 1 3
expr1
statement2 ? n1
case 2: 2
(b) statm3 n2 n3 n4
statm2 statm3 statm4
case 3:
statm4
end switch
n5
statm5 statm5
statm1
do n1
statement1
while expr2 T
(c) expr2
n2
end do ?
statement3 F
n3
statm3 26
EXAMPLE PATHS
if expression1
then Paths:
statement2 e1 n1
P1 = e1, e2, e4, e6, e7, e8
end if n2 e3
P2 = e1, e2, e4, e5, e4, e6, e7, e8
e2 n3
do P3 = e3, e4, e6, e7, e8, e10
e4 e5
statement3 n4
P4 = e6, e7, e8, e10, e3, e4
while expr4 e6 P5 = e1, e2, e4, e6, e9, e10
end do e7 n5 P6 = e4, e5
n6 e9
P7 = e3, e4, e6, e9, e10
if expression5 e8 n7 P8 = e1, e2, e4, e5, e4, e6, e9, e10
then
statement6
end if
V(G) = e – n + 2 = 9 – 7 + 2 = 4
statement7
27
EXAMPLE 1
28
V=e-n+2=11-9+2=4
29
30
V=e-n+2=11-9+2=4
31
BLACK-BOX TESTING
BLACK BOX TESTING
35
QUESTIONS ANSWERED BY
BLACK-BOX TESTING
How is functional validity tested?
How are system behavior and performance tested?
What classes of input will make good test cases?
Is the system particularly sensitive to certain input
values?
How are the boundary values of a data class isolated?
What data rates and data volume can the system
tolerate?
What effect will specific combinations of data have on
system operation?