English: The black box testing and white box testing involves in database testing. (Photo credit: Wikipedia) |

**Tools used for White Box testing:**

Few Test automation tool vendors offer white box testing tools which:

- Provide run-time error and memory leak detection;

- Record the exact amount of time the application spends in any given block of code for the purpose of finding inefficient code bottlenecks; and

- Pinpoint areas of the application that have and have not been executed.

1 Basis Path Testing

Basis path testing is a

*white box testing*technique first proposed by Tom McCabe. The Basis path method enables 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.
2 Flow Graph Notation

The flow graph depicts logical control flow using a diagrammatic notation. Each structured construct has a corresponding flow graph symbol.

3 Cyclomatic Complexity

*Cyclomatic complexity is a software metric that provides a quantitative measure of the logical complexity of a program.*When used in the context of a basis path testing method, the value computed for Cyclomatic complexity defines the number for independent paths in the basis set of a program and provides us an upper bound for the number of tests that must be conducted to ensure that all statements have been executed at least once.

An

*independent path*is any path through the program that introduces at least one new set of processing statements or a new condition.**Computing Cyclomatic Complexity**

Cyclomatic complexity has a foundation in graph theory and provides us with extremely useful software metric. Complexity is computed in one of the three ways:

- The number of regions of the flow graph corresponds to the Cyclomatic complexity.

- Cyclomatic complexity, V(G), for a flow graph, G is defined as
**V (G) = E-N+2**

Where E, is the number of flow graph edges, N is the number of flow graph nodes.

Cyclomatic complexity, V (G) for a flow graph, G is also defined as:

**V (G) = P+1**
Where P is the number of predicate nodes contained in the flow graph G.

4 Graph Matrices

The procedure for deriving the flow graph and even determining a set of basis paths is amenable to mechanization. To develop a software tool that assists in basis path testing, a data structure, called a

*graph matrix*can be quite useful.
A

*Graph Matrix*is a square matrix whose size is equal to the number of nodes on the flow graph. Each row and column corresponds to an identified node, and matrix entries correspond to connections between nodes.
5 Control Structure Testing

Described below are some of the variations of Control Structure Testing.

**Condition Testing**

Condition testing is a test case design method that exercises the logical conditions contained in a program module.

**Data Flow Testing**

The data flow testing method selects test paths of a program according to the locations of definitions and uses of variables in the program.

6 Loop Testing

Loop Testing is a white box testing technique that focuses exclusively on the validity of loop constructs. Four classes of loops can be defined: Simple loops, Concatenated loops, nested loops, and unstructured loops.

**Simple Loops**

The following sets of tests can be applied to simple loops, where ‘n’ is the maximum number of allowable passes through the loop.

1. Skip the loop entirely.

2. Only one pass through the loop.

3. Two passes through the loop.

4. ‘m’ passes through the loop where m<n.

5. n-1, n, n+1 passes through the loop.

**Nested Loops**

If we extend the test approach from simple loops to nested loops, the number of possible tests would grow geometrically as the level of nesting increases.

- Start at the innermost loop. Set all other loops to minimum values.
- Conduct simple loop tests for the innermost loop while holding the outer loops at their minimum iteration parameter values. Add other tests for out-of-range or exclude values.
- Work outward, conducting tests for the next loop, but keep all other outer loops at minimum values and other nested loops to “typical” values.
- Continue until all loops have been tested.

**Concatenated Loops -**Concatenated loops can be tested using the approach defined for simple loops, if each of the loops is independent of the other. However, if two loops are concatenated and the loop counter for loop 1 is used as the initial value for loop 2, then the loops are not independent.

**Unstructured Loops -**Whenever possible, this class of loops should be redesigned to reflect the use of the structured programming constructs.

## Post a Comment