Presentation is loading. Please wait.

Presentation is loading. Please wait.

Agenda Introduction Overview of White-box testing Basis path testing

Similar presentations


Presentation on theme: "Agenda Introduction Overview of White-box testing Basis path testing"— Presentation transcript:

1 White-Box Testing Based on Pressman Ch 17 (5th edition) or Ch 14 (6th edition)

2 Agenda Introduction Overview of White-box testing Basis path testing
Control structure testing Ref. Video:

3 Internal and External Views
Any engineered product (and most other things) can be tested in one of two ways: Knowing the specified function that a product has been designed to perform, tests can be conducted that demonstrate each function is fully operational while at the same time searching for errors in each function; Knowing the internal workings of a product, tests can be conducted to ensure that "all gears mesh," that is, internal operations are performed according to specifications and all internal components have been adequately exercised.

4 Test Case Design "Bugs lurk in corners and congregate at
boundaries ..." Boris Beizer OBJECTIVE to uncover errors CRITERIA in a complete manner CONSTRAINT with a minimum of effort and time

5 What is a ‘Good’ Test? A good test has a high probability of finding an error. A good test is not redundant. A good test should be “best of breed”. A good test should be neither too simple nor too complex.

6 Exhaustive Testing Executing a program with all possible combinations of inputs or values for program variables Computer Dictionary Online

7 Exhaustive Testing There are 10 possible paths! If we execute one
loop < 20 X 14 There are 10 possible paths! If we execute one test per millisecond, it would take 3,170 years to test this program!!

8 Selective Testing Selected path loop < 20 X

9 White-Box Testing our goal is to ensure that all
statements and conditions have been executed at least once ...

10 White-Box Testing (cont.)
It is a test case design approach that uses the control structure (described as part of procedural design) to DERIVE test cases. We can derive test cases that: Guarantee that all independent paths within a module have been exercised/covered 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.

11 Why Cover? Logic errors and incorrect assumptions
are inversely proportional to a path's execution probability. We often believe that a path is not likely to be executed; in fact, the reality is often counter intuitive. Typographical errors are random; it's likely that untested paths will contain some.

12 Cyclomatic Complexity
A measure of the number of linearly independent paths through a program module Cyclomatic Complexity is a measure for the complexity of code related to the number of ways there are to traverse a piece of code. This determines the minimum number of inputs you need to test all ways to execute the program. A software metric that provides a quantitative measure of the logical complexity of a program.

13 Cyclomatic Complexity
A number of industry studies have indicated that the higher V(G), the higher the probability of errors. modules V(G) modules in this range are more error prone

14 Basis Path Testing It is one of the main ‘white-box’ testing techniques. It enables the test case designer to derive a logical complexity measure of a procedural design and use 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.

15 Basis Path Testing - Steps
Using the design or code as a foundation, draw a corresponding control flow graph. Determine the cyclomatic complexity of the graph. Determine a basis set of linearly independent paths. Prepare test cases that will force execution of each path in the basis set.

16 Basis Path Testing – e.g. First, we compute the cyclomatic complexity:
the number of simple decisions + 1 or the number of enclosed areas + 1 In this case, V(G) = 4

17 Basis Path Testing e.g. Next, we derive the independent paths:
1 Since V(G) = 4, there are four paths 2 Path 1: 1,2,3,6,7,8 3 4 Path 2: 1,2,3,5,7,8 5 6 Path 3: 1,2,4,7,8 Path 4: 1,2,4,7,2,4,...7,8 7 Finally, we derive test cases to exercise these 8 paths.

18 Basis Path Testing - Notes
You don't need a flow chart, but the picture will help when you trace program paths. Count each simple logical test, compound tests count as 2 or more. Basis path testing should be applied to critical modules.

19 Flow Graph Notation Flow Graph or Program Graph
The representation of control flow Depicts logical control flow.

20 Flow Graph Notation (cont.)

21 Flowchart and Flow Graph

22 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. Each row and column corresponds to an identified node, and matrix entries correspond to connections (an edge) between nodes. By adding a link weight to each matrix entry, the graph matrix can become a powerful tool for evaluating program control structure during testing.

23 Graph Matrices – e.g.

24 Control Structure Testing
The basis path testing is simple and effective, but it is not sufficient in itself. Control structure testing techniques broaden testing coverage and improve quality of white-box testing.

25 Control Structure Testing
Basis path testing Condition testing — exercises the logical conditions contained in a program module. Data flow testing — selects test paths of a program according to the locations of definitions and uses of variables in the program. Loop testing — focuses exclusively on the validity of loop constructs.

26 Condition Testing – e.g. A simple/basic condition is a Boolean variable or a relational expression (e.g. m>n, x+5<= 2*y, etc) A compound (or multiple) condition is composed of two or more simple conditions, Boolean operators, and parentheses. For example m>n AND x+5<=2*y, m>n OR x+5<=2*y, etc.

27 Multiple Conditions - 1 1 2 S2 S1 F T F T
If (A > 5) and (B < 10) then S1 else S2; 1 F T F Conditions: 1 A > 5 2 B < 10 2 T S2 S1

28 Multiple Conditions - 2 1 2 S1 S2 T F T F
If (A > 5) or (B < 10) then S1 else S2; F T 2 Conditions: 1 A > 5 2 B < 10 F S1 S2

29 Loop Testing Simple loop Nested Loops Concatenated Loops Unstructured

30 Loop Testing: Simple Loops
Minimum conditions—Simple Loops 1. skip the loop entirely 2. only one pass through the loop 3. two passes through the loop 4. m passes through the loop m < n 5. (n-1), n, and (n+1) passes through the loop where n is the maximum number of allowable passes

31 Loop Testing: Nested Loops
Start at the innermost loop. Set all outer loops to their minimum iteration parameter values. Test the min+1, typical, max-1 and max for the innermost loop, while holding the outer loops at their minimum values. Move out one loop and set it up as in step 2, holding all other loops at typical values. Continue this step until the outermost loop has been tested. If the loops are independent of one another then treat each as a simple loop else* treat as nested loops endif* for example, the final loop counter value of loop 1 is used to initialize loop 2. Nested Loops Concatenated Loops

32 Summary Overview of White-box testing Basis path testing
Other control structure testing


Download ppt "Agenda Introduction Overview of White-box testing Basis path testing"

Similar presentations


Ads by Google