White Box Testing

13
by : Andika Bayu H

description

White Box Testing. by : Andika Bayu H. Introduction. White Box Testing or Glass Box Testing Test case design method that uses the control structure of the procedural design to derive test cases SW Engineer can derive test cases that - PowerPoint PPT Presentation

Transcript of White Box Testing

Page 1: White Box Testing

by : Andika Bayu H

Page 2: White Box Testing

White Box Testing or Glass Box Testing◦ Test case design method that uses the control structure of the

procedural design to derive test cases SW Engineer can derive test cases that

◦ guarantee that all independent paths within a module have been exercised at least once

◦ exercise all logical decisions on their true and false bounds◦ execute all loops at their boundaries and within their operational bounds◦ exercise internal data structures to assure their validity

Why not just validate the requirement ?◦ Logic errors and incorrect assumptions are inversely proportional to the

probability that a program path will be executed◦ We often believe that a logical path is not likely to be executed when, in

fact, it may be executed on a regular basis◦ Typographical errors are random

2

Page 3: White Box Testing

Proposed by Tom McCabe The basis path method 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

Flow Graph Notation:

3

Sequence

If

While

Repeat - UntilCase

Page 4: White Box Testing

Procedure Sort

4

Procedure Sort1. do while not eof2. Read Record3. if record field 1 = 04. then process record5. store in buffer;6. increment counter7. else if record field 2 = 08. then reset counter9. else process record10. store in file11. endif12. endif13. enddo

1

3

7

11

12

2

4

598

610

• Flow Chart

Page 5: White Box Testing

5

Flow Chart - Flow Graph Flow Chart - Flow Graph

1

3

7

11

12

2

4

598

610

• Flow Chart

1

2,3

7

4,5,69,108

11

12

• Flow Graph

Page 6: White Box Testing

6

IF a or b

then procedure X

else procedure Y

endif

a

b

xxy

P red ica te N ode

Page 7: White Box Testing

Cyclomatic Complexity ◦ software metric that provide a quantitative

measure of the logical complexity of a program]

7

V(G) = E - N + 2

V(G) = 9 - 8 + 2 = 3

• The number of regions of the flow graph correspond to the cyclomatic complexity.

• V(G) = P + 1, where P is the number of predicate nodes

Page 8: White Box Testing

An independent path is any path through the program that introduces at least one new set of processing statements or a new condition

An independent path must move along at least one edge that has not been traversed before the path is defined

8

1

2,3

7

4,5,69,108

11

1213

path 1: 1-13

path 2: 1-2-3-7-8-11-12-1-13

path 3: 1-2-3-7-9-10-11-12-1-13

path 4: 1-2-3-4-5-6-12-1-13

Is the path

1-2-3-4-5-6-12-1-2-3-7-8-11-12-1-13

an independent path ?

Page 9: White Box Testing

Draw a corresponding flowgraph using the design or code as a foundation

Determine the cyclomatic complexity of the resultant flow graph (V(g))

Determine a basis set of linearly independent paths

Prepare test cases that will force execution of each path in the basis set◦ if we have 6 independent paths, then we should have

at least 6 test cases. For each test cases, we should define the input conditions and the expected result.

9

Page 10: White Box Testing

Can automate derivation of flow graph and determination of a set of basis paths.

Software tools to do this can use a graph matrix.

Graph matrix:

is square with #sides equal to #nodes

Rows and columns correspond to the nodes

Entries correspond to the edges.

Can associate a number with each edge entry.

Use a value of 1 to calculate the cyclomatic complexity

For each row, sum column values and subtract 1.

Sum these totals and add 1.

10

Page 11: White Box Testing

11

Some other interesting link weights: Probability that a link (edge) will be executed Processing time for traversal of a link Memory required during traversal of a link

Resources required during traversal of a link

Page 12: White Box Testing

Loop is fundamental to many algorithms.

Loop can be defined as simple, concatenated, nested, and unstructured.

12

Sim ple Loops

N ested Loops

ConcatenatedLoops

U nstructuredLoops

Page 13: White Box Testing

To test:

Simple Loops of size n: Skip loop entirely Only one pass through loop Two passes through loop m passes through loop where m<n. (n-1), n, and (n+1) passes through the loop.

Nested Loops Start with inner loop. Set all other loops to minimum values. Conduct simple loop testing on inner loop. Work outwards Continue until all loops tested.

Concatenated Loops If independent loops, use simple loop testing. If dependent, treat as nested loops.

Unstructured loops Don't test - redesign.

13