KEMBAR78
Software Testing | PDF | Control Flow | Computer Program
0% found this document useful (0 votes)
5 views11 pages

Software Testing

Uploaded by

w7p8y2y7fj
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)
5 views11 pages

Software Testing

Uploaded by

w7p8y2y7fj
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
You are on page 1/ 11

7/10/2025

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.

1
7/10/2025

White box testing

White-box Testing

These test cases


Guarantee that all independent paths within a module have
been exercised at least once
Exercise all logical decisions on their true and false sides
Execute all loops at their boundaries and within their
operational bounds
Exercise internal data structures to ensure their validity

2
7/10/2025

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

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)
 An edge, or a link, is a an arrow representing flow of control in a specific
direction
 An edge must start and terminate at a node
 An edge does not intersect or cross over another edge

3
7/10/2025

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

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

4
7/10/2025

Cyclomatic Complexity

• Provides a quantitative measure of the logical complexity of a program


• Defines the number of independent paths in the basis set
• Provides an upper bound for the number of tests that must be conducted to
ensure all statements have been executed at least once
 Can be computed two ways
 V(G) = E – N + 2, where E is the number of edges and N is the number of nodes in
graph G
 V(G) = P + 1, where P is the number of predicate nodes in the flow graph G
 Results in the following equations for the example flow graph
 V(G) = 14 edges – 12 nodes + 2 = 4
 V(G) = 3 predicate nodes + 1 = 4

Deriving the Basis Set and Test Cases

1. Using the design or code as a foundation, draw a corresponding flow


graph
2. Determine the cyclomatic complexity of the resultant flow graph
3. Determine a basis set of linearly independent paths
4. Prepare test cases that will force execution of each path in the basis
set

5
7/10/2025

Cyclomatic Complexity

 Invented by Thomas McCabe (1974) to


measure the complexity of a program’s
conditional logic
 Cyclomatic complexity of graph G equals
#edges - #nodes + 2
 V(G) = e – n + 2

 Also corresponds to the number of linearly


independent paths in a program

Converting Code to Graph

CODE FLOWCHART 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
statm2 statm3 statm4 n2 n3 n4
case 3:
statm4
end switch
n5
statm5 statm5

statm1 n1
do
statement1
T
(c) while expr2 expr2
n2
end do ?
statement3 F
n3
statm3

6
7/10/2025

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
e4 e5
statement3 n4
P4 = e3, e4, e5, e4, e6, e7, e8
while expr4 e6 P5 = e1, e2, e4, e6, e9
end do e7 n5 P6 = e3, e4, e5, e4, e6, e9
n6 e9
P7 = e3, e4, e6, e9
if expression5 e8 n7 P8 = e1, e2, e4, e5, e4, e6, e9
then
statement6
end if
V(G) = e – n + 2 = 9 – 7 + 2 = 4
statement7

Example 1

7
7/10/2025

V=e-n+2=11-9+2=4

8
7/10/2025

V=e-n+2=11-9+2=4

Black-box Testing

9
7/10/2025

Black Box Testing

Test cases are derived from formal specification of the


system.
Test case selection can be done without any reference
to the program design or code.
Only tests the functionality and features of the program.
Not the internal operation.
Advantages
 Test case selection is done before the
implementation of a program.
 Help in getting the design and coding correct with
respect to the specification.

Black box

10
7/10/2025

Black-box Testing Categories

• Incorrect or missing functions


• Interface errors
• Errors in data structures or external data base access
• Behavior or performance errors
• Initialization and termination errors

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?

11

You might also like