White Box Testing: Anuja Arora Cse / It Jiitu, Noida
White Box Testing: Anuja Arora Cse / It Jiitu, Noida
Structural testing
1 2 3 6 7 8 6
2,3
4,5 8
4
5
7 9
10 11
def = { x , y } c-use =
y
2 4
def = { z } c-use =
5
def = { z , pow } c-use = { x , z , pow }
pow
y
def = c-use =
y
def = { z } c-use = { z }
def = c-use = { z }
j mean a path from node i to j w.r.t. a variable x. similarly , there is def clear path from i to ( j, k )
Path testing
The objective of path testing is to ensure that the set of test cases is such that each path through the program is executed at least once. The starting point for path testing is a program flow graph that shows nodes representing program decisions and arcs representing the flow of control. Statements with conditions are therefore nodes in the flow graph.
example
PROCEDURE average; *This procedure computes the avearage of 100 or fewer number that lie between bounding values; It also compute the sum and total number valid INTERFACE RETURNS average,total.input,total.valid; INTERFACE ACCEPT values,minimum,maximum; TYPE values[1:100] IS SCALAR ARRAY; TYPE i IS INTEGER; i = 1; total.input = total.valid = 0; Sum = 0; DO WHILE value [i] <>-999 AND total.input <100
1 4 5
2 3 6
increment total.input by 1 IF value [i] > = minimum AND value [i] < = maximum THEN increment total.valid by 1; sum= s sum + value [i] ELSE skip ENDIF increment i by 1; END DO IF total.valid > 0
8 9
10 11 12
13 ENDIF
Cyclomatic complexity
It is a software metric that provides a quantitative measure of the logical complexity of a program The value computed for cyclomatic complexity Defines the number of independent path in the basic set of a program Provide us the number of upper bound for the number of tests that must be conducted to ensure that all statement have been executed at least once.
1 2 3 4
10
R1, R2
5 12 8
R5,R6 R4
6
R3
13
Independent paths
path 1 : path 2 : path 3 : path 4 : path 5 : path 6 : path 7 : 1-2-10-11-13 1-2-10-12-13 1-2-3-10-11-13 1-2-3-10-12-13 1-2-3-4-5-8-9-2-.. 1-2-3-4-5-6-8-9-2- 1-2-3-4-5-6-7-8-9-2-
Independent paths
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14 1, 2, 3, 4, 5, 14 1, 2, 3, 4, 5, 6, 7, 11, 12, 5, 1, 2, 3, 4, 6, 7, 2, 11, 13, 5, Test cases should be derived so that all of these paths are executed A dynamic program analyser may be used to check that paths have been executed
Graph Matrices
Tabular representation of a flow graph.
1
a e f g
1 2 1 2 3 4 5
a d c g e b f
3
b
4
2
d c
3 4 5
Adding link weight to each matrix entry, most powerful tool for evaluating program control structure during testing.
Graph Matrices(cont.)
In simplest form link weight is 1(connection exist) or 0(connection not exist) Link weight can be assigned other:
The probability that a link (edge) will be executed Processing time expanded during traversal of a link The memory required during traversal of a link . The resource required during traversal of a link .
Key points
Testing can show the presence of faults in a system; it cannot prove there are no remaining faults. Component developers are responsible for component testing; system testing is the responsibility of a separate team. Integration testing is testing increments of the pow system; release testing involves testing a system to be released to a customer. Use experience and guidelines to design test cases in defect testing.
Key points
Interface testing is designed to discover defects in the interfaces of composite components. Equivalence partitioning is a way of discovering test cases - all cases in a partition should behave in the same way. Structural analysis relies on analysing a program and deriving tests from this analysis.