Chapter 23 - Conventional Testing
Chapter 23 - Conventional Testing
Testing Conventional
Applications
R.Bhavani
AP/CSE/SRC
Introduction
The primary objective for test-case design
is to derive a set of tests that have the
highest likelihood for uncovering errors in
software.
Methods
Strategies
White-box testing
Sequence UNTIL
IF
CASE
WHILE
Procedures to construct flow graph from
flow chart
Each circle, called a flow graph node, represents one or more procedural
statements
A sequence of process boxes and a decision diamond (predicate node)
can map into a single node.
The arrows on the flow graph, called edges or links, represent
flow of control and are analogous to flowchart
arrows.
Area bounded by edges and nodes are called regions.
When counting regions, we include the area outside the1 graph as region.
Edge
1
2,3 Node
2
6 4,5
R2
3
7 R3 8
6 4
R1 Region
9
7 8 5 R4
9 10
10
8
11
11
Flow graph
Region
4
edges Region 6
Region 5
Region 3
Region 1
Region 2
Flow graph – Compound Statement
Predicate
node a
.
. b x
.
IF a OR b
then procedure y x
x
else procedure
y
ENDIF
Path 1: 1-11
1 Path 2: 1-2-3-4-5-10-1-11
Edge
Path 3: 1-2-3-6-8-9-10-1-11
Node
2,3
Path 4: 1-2-3-6-7-9-10-1-11
6
R2 4,5 Each new path introduces a new
7 R3 8 edge.
R1 Region
9
10
R4 But the path
Path 5: 1-2-3-4-5-10-1-2-3-6-8-9-
11 10-1-11 – Combination of already
specified
Independent path programs & Cyclomatic
Complexity
Cyclomatic Complexity - software metric that provides
a quantitative measure of the logical complexity of a
program.
Defines the number of independent paths in the basis
set of a program
Provides with an upper bound for the number of tests
that must be conducted to ensure that all statements
have been executed at least once.
Cyclomatic Complexity
Calculation of Cyclomatic Complexity V(G) by three methods:
Method 1
V(G) = e – n + 2 ( Where “e” are edges & “n” are nodes)
Method 2
V(G) = P + 1 (Where P- predicate nodes with out-degree = 2)
Method 3
V(G) = Number of regions
1
Edge
2,3 Node
R1 Region
2.V(G) = 3 predicate nodes + 1 = 4
9
R4
10
3.V(G) = 4 regions = 4
11
Example 2: Sample Program
void foo (float y, float a *, int n)
{
float x = sin (y) ;
if (x > 0.01)
z = tan (x) ;
else
z = cos
(x) ;
1
void foo (float y, float a *, int n) 1
{
float x = sin (y) ; R1
2 3
if (x > 0.01) 2
z = tan (x) ;
else 3 Predicate
4
R3
z = cos (x) ; nodes
4 5 6
for (int i = 0 ; i < x ; + + i) { 5 R2
a[i] = a[i] * z ; 6
6
Cout < < a [i]; } 6
} 7 7
Example 2
Step 2: Identify independent paths
• There are 3 paths in this program which are
independent paths and they form a basis-set.
• These paths are described below
Path 1: 1 – 2 – 4 – 5 - 7
Path 2: 1 – 3 – 4 – 5 - 7
Path 3: 1 – 2 – 4 – 5 – 6 – 5 – 7
Path 4: 1 – 3 – 4 – 5 – 6 – 5 – 7
• We must execute these paths at least once in order to test the
program thoroughly.
• Accordingly we can design the test cases (no of test cases =>
3)
Example 2
Step 3: Calculate cyclomatic complexity,
V(G)
Calculation of V(G) by three methods:
Method 1
V(G) = e – n + 2 ( Where “e” are edges & “n” are
nodes) V(G) = 8 – 7 + 2 = 3
Method 2
V(G) = P + 1 (Where P- predicate nodes with out-degree = 2)
V(G) = 2 + 1 = 3 (The predicate nodes are labeled)
Method 3
V(G) = Number of regions = 3
Example 3 Example 4
Flow graph Flow chart
1 1
2 2
3 3
8 4
5 6
4 5
6 7
7
8
9
Example 3
Step 2: Identify independent paths
1
3
8
4 5
6
7 Path 1: 1-9
Path 2: 1-2-8-7-1-9
Path 3: 1-2-3-4-6-7-1-9
9 Path 4: 1-2-3-5-6-7-1-9
Example 3
Step 3: Calculate cyclomatic complexity, V(G)
V(G) = E - N + 2
V(G) = 11 - 9 + 2 = 4
E= no. of edges,
2 N= no. of
nodes
1
3
4
V(G) = P + 1
V(G) = 3 + 1 =
4
P= no. of predicate nodes
(conditions) # Regions = 4
Example 4
Flow chart
3
4
5 6
25
Example 4
Step 2: Identify independent paths
Predicate
1
nodes
Path 1: 1,2,3,6,7,8
Path 2: 1,2,3,5,7,8
Path 3: 1,2,4,7,8
2
Path 4: 1,2,4,7,2,4,...7,8
R1
3
4
5 6 R4
R2
R3 Predicate
nodes edges
7
Predicate
nodes
8
Example 4
Step 3: Calculate cyclomatic complexity,
V(G)
Calculation of V(G) by three methods:
Method 1
V(G) = e – n + 2 ( Where “e” are edges & “n” are
nodes) V(G) = 9 – 7 + 2 = 4
Method 2
V(G) = P + 1 (Where P- predicate nodes with out-degree = 2)
V(G) = 3 + 1 = 4 (The predicate nodes are labeled)
Method 3
V(G) = Number of regions = 4
Graph Matrices
A graph matrix is a square matrix whose size (i.e.,
number of rows and columns) is equal to the number
of nodes on a flow graph
1. read x, y;
2. if(x>y)
3. a = x+1
else
4. a = y-1
5. print a;
DEFINED AT USED AT
VARIABL
NODE NODE
E
x 1 2, 3
y 1 2, 4
a 3, 4 5
Loop testing
Loop testing is a white-box testing technique
that focuses exclusively on the validity of
loop constructs.
Examples of types of loop tested are,
Simple loop
Nested loop
Concatenated loop
Unstructured loop
Simple Loop testing
44
Graph-based testing - Uses number
of behavioral testing methods
Modeling Nodes Links
A nominal value
Maximum
1.
Anom, Bmin
2.
3. Anom, Bmin+
4.
Anom, Bmax
5.
6. Anom, Bmax-
7.
Amin, Bnom
8.
9. Amin+, Bnom
EX: Boundary Value Checking
A program reads an integer number (1,100)
and checking whether it is a prime number.
Min = 1
Min+ = 2
Max = 100
Max- = 99
BVC= 4n +1 = 5
1.
2.
Anom, Bmin 10.Amax+, Bnom
3. Anom, Bmin+ 11.Amin-, Bnom
4. 12.Anom, Bmax+
Anom, Bmax
5.
6. Anom, Bmax-
13.Anom, Bmin-
7.
Amin, Bnom
8.
9. Amin+, Bnom
EX: Robustness Testing Method
A program reads an integer number (1,100)
and checking whether it is a prime number.
Min- = 0 Max = 100
Min = 1 Max- = 99
Min+ = 2 Max+=101
Nominal Value = 50-55
RTM = 6n+1 = 7
Min = 1
Min+ = 2
Max- = 99
1 100C
2 100C
3 100C
4 150C
5 150C
6 150C
7 200C
8 200C
9 200C
EX: Orthogonal Array Testing
3. Now split up the pressure, doping amount and the deposition
rates in the columns.
For eg: Enter 2 psi across temperatures 100C,150C and 200C
likewise enter doping amount 4% for 100C,150C and 200C and
so on. Hence, in OAs, we need 9 Test cases to cover.
System testing. Software and hardware are integrated, and a full range
of system tests are conducted in an attempt to uncover errors at the
software- hardware interface.
Are interrupt priorities properly assigned and properly handled?
Is processing for each interrupt handled correctly?
Does the performance (e.g., processing time) of each interrupt-handling
procedure conform to requirements?
Does a high volume of interrupts arriving at critical times create problems
in function or performance?
Thank You!