Download presentation
Presentation is loading. Please wait.
1
Software Testing and Quality Assurance
Lecture 8 - Software Testing Techniques
2
Lecture Outline Discuss testing techniques based on achieving coverage of the software. Control-flow testing Data-flow testing Static Data-flow testing
3
Coverage Based Testing
To achieve some form of coverage of the program-under- test based on well-defined-criteria Rather than partitioning the input domain of the program.
4
Control-flow Testing Aims to understand the flow of control within a program. Select test inputs to exercise paths in the Control-Flow Graph (CFG). Paths are selected based on the control information in the graph. Examples of coverage criteria include: Path coverage Branch coverage condition coverage
5
Control-flow Graphs Control-flow is a graph G = (V,E) where;
Vertex represents a program statement Edge represents the ability of a program to flow from its current statement to the next statement. If an edge is associated with a conditional statement, label the edge with the conditional value, either true or false.
6
Control-flow Graphs - Example
Int power (int base, int n) { int power i; power = 1; for (i = 1; I ≤ n; i ++) { power = base * power; } Return power;
7
Control-flow Graphs - Example
int base, int n int power, 1 Power = 1 i = 1 i = i + 1 I ≤ n Power = base * power return power
8
Control-flow Graphs - Example
int base, int n Execution Path Condition int power, 1 Power = 1 i = 1 Branch or decision i = i + 1 I ≤ n Power = base * power return power
9
Coverage Based Criteria
Statement - every statement of the program should be exercised at least once. Branch coverage - every possible alternative in a branch of the program should be tested at least once. Condition coverage - each condition in a branch is made to evaluate to true or false.
10
Coverage Based Criteria
Multiple condition coverage All possible combinations of condition outcomes within each branch should be exercised at least once. For example, if (a&&b) --- evaluate all possible combinations. Path coverage Every execution path of the program should be exercised at least once.
11
For example, program with 5 input variables
Data-Flow Testing Despite analysis of input and output domains used in Equivalence partitioning, boundary value analysis, and control flow Testing relies on personal experience to choose test cases. For example, program with 5 input variables 3125 possible EC
12
Complement coverage based testing.
Data-Flow Testing Information about the creation and use of data definitions in a program. Detect many single programming or logical faults in the program; Provide testers with dependencies between the definitions and use of variables. Complement coverage based testing.
13
Static Data-Flow Testing
Simplest form of data-flow analysis A programming language statement can act on a variable in 3 different ways. Define a variable Reference a variable Undefined a variable
14
Static Data-Flow Testing - Define (d)
A statement defines a variable by assigning a value to a variable. For example, x = 5; Scan (x); x = 3 * y; Defined the variable x Only defined the variable x If y is declared and defined.
15
Static Data-Flow Testing - Reference (r)
A statement makes a reference to a variable either as an: I-value - variable, array cell into which values can be stored. A variable that appears on the left hand side of an assignment statement. R -value - any variable that must be referenced to get its value. A variable that appears on the right hand side of an assignment statement.
16
Static Data-Flow Testing - Un-define (u)
A statement un-defines a variable whenever the value of the variable becomes unknown. For example, The scope of a local variable ends.
17
Static Data-Flow Testing - Anomalies
u-r anomaly Undefined variable is referenced. For example, un-initialized variable. d-u anomaly A defined variable has not been referenced before it becomes undefined. d-d anomaly Same variable is defined twice. Usually due to misspelling or because variables have been imported from another function.
18
Action on variable c No action A B Define C False reference D E
Int i,j; int *c; B Define C = malloc(….) C Error (….) c = Null False reference D C [0] = 1; c[1] = 1; sum = 2; E No action i = 2 F H False G I ≤ n Return sum; True reference I C [i] = c[I-1] + c[I-2]; sum += c[I]; Un-define Fee (c) J No action I++ K u-r anomaly
19
Key points Control-Flow Testing aims to understand the flow of control within a program. Most common - Control-Flow Graph Data-Flow Testing Provides additional information to use for program analysis and testing. Static Data-Flow Analysis Typing errors Un-initialized variables, Misspelling of names etc.
20
Announcement Quiz 2 moved from Material Wednesday 29/10/2008 to
Saturday 01/11/2008. Material Lec 6, Lec 7,Lec 8 & Lec 9
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.