Lecture - Testing
Lecture - Testing
ENGINEERING
LECTURE 10 - TESTING
WHAT IS TESTING
WHAT IS TESTING
TYPES
TYPES
TYPES
TYPES
TYPES
TYPES
TYPES
TYPES
BASIC PATH TESTING
INTRODUCTION
• A white box method
• Proposed by McCabe in 1980’s
• A hybrid of path testing and branch
testing methods.
• Based on Cyclomatic complexity and
uses control flow to establish the path
coverage criteria.
CYCLOMATIC
COMPLEXITY
• Developed by McCabe in 1976
• Measures the number of linearly
independent paths through a program.
• The higher the number the more
complex the code.
BASIC PATH TESTING
• Step 1: Draw a control flow graph.
• Step 2: Determine Cyclomatic
complexity.
• Step 3: Find a basis set of paths.
• Step 4: Generate test cases for each
path.
BASIC PATH TESTING
• Basic data flow structure
BASIC PATH TESTING
• Basic data flow structure
⮚Arrows or edges represent flows of
control.
⮚Circles or nodes represent actions.
⮚Areas bounded by edges and nodes
are called regions.
⮚A predicate node is a node containing
a condition.
BASIC PATH TESTING
• Draw basic data flow structure
1: IF A = 100
2: THEN IF B > C
3: THEN A = B
4: ELSEA= C
5: ENDIF
6: ENDIF
7: Print A
BASIC PATH TESTING
Determine Cyclomatic complexity
• There are several methods:
1. Cyclomatic complexity = edges - nodes + 2p
Cyclomatic complexity =
number of regions in the control flow graph
BASIC PATH TESTING
Find a basis set of paths
BASIC PATH TESTING
EXAMPLES
EXAMPLE 1
1. If (num==1000)
2. statement 1
3. Else statement 2
4. Endif
-----------------------------
• No. of nodes =
• No. of edges =
• No. of predicate nodes =
EXAMPLE 2
1. If (num==1000)
2. statement 1
3. Else {statement 2
4. statement 3}
5. Endif
-----------------------------
• No. of nodes =
• No. of edges =
• No. of predicate nodes =
• No. of regions =
EXAMPLE 3
1. while (num==1000)
2. statements
3. End while
-----------------------------
• No. of nodes =
• No. of edges =
• No. of predicate nodes =
•
EXAMPLE 4
1. switch (ch)
2. { case ‘1’: s1; break;
3. case ‘2’: s2; break;
4. case ‘3’: s3; break;
5. case ‘4’: s4; break;
6. default: s5;}
7. end
-----------------------------
• No. of nodes =
• No. of edges =
• No. of predicate nodes =
EXAMPLE 5
if (1. a > 100 and 2. b < 200)
3. statement1
else
4. statement 2
5.elseif
-----------------------------
• No. of nodes =
• No. of edges =
• No. of predicate nodes =
• No. of regions =