Monday, January 24, 2011

TESTING - TESTING TECHNIQUES - White Box Testing:

- Tests internal program logic. ie., tests the basic program structure.

Purpose of unit Tests:

- Tests all loops.

- Test basis paths.

- Test conditional statements.

- Test data structures.

Reasons for white box testing:

- Normal path processing can be well understood.

- Exception handling is less well scrutinized or specified in requirement and when coded is therefore more susceptible to errors.

- Likely that a type will be discovered in an obscure logic path as a main processing path.

- Black box testing is much less likely to uncover subtle logic errors (more appropriate for higher level tests of functionality).

Developing Unit Tests:

- Identify units to be unit-tested.

- Identify test cases.

- Develop the test cases.

Basis path testing:

- Tom McCabe’s cyclomatic complexity metric:

· Measures the logical complexity of a procedural design.

· Provides flow-graph notation to identify independent paths of processing.

· Once paths are identified, tests can be developed for loops, conditions.

· Process guarantees that every statement will get executed atleast once.

Developing Unit Tests:

- Compute cyclomatic complexity of all complex units.

- Identify units in the 20th percentile of complexity: those most critical/complex.

- Define basis paths for all units.

- Define predicate test (conditional tests) for all units in the 20th percentile.

Flow Chart Notation

Flow Graph Notation

Flow graph Notation – Edges, nodes & regions

Computing cyclomatic complexity:

V(G) = E – N + 2 = 11 – 9 + 2 = 4

V(G) = P + 1 = 3 + 1 = 4

V(G) = the number of regions (closed spaces, plus the open space) = 4

Flow Graph Notation:

- Predicate nodes are any nodes with branching.

A Unique/Independent path:

- Is one where atleast one new edge is transverse.

Basis Path Set:

- Is a set of paths where all unique/independent paths are represented. Ie, the set is not unique.

4 comments: