TEST CASE DESIGN PART TWO

Basis Path Testing

Aim is to derive a logical complexity measure of a procedural design and use this as a guide for defining a basic set of execution paths.

Test cases, which exercise basic set, will execute every statement at least once.

Flow Graph Notation

Flow graph notation helps to represent various control structures of any programming language. Various notations for representing control flow are:

On a flow graph:

  • Arrows called edges represent flow of control

  • Circles called nodes represent one or more actions.

  • Areas bounded by edges and nodes called regions.

  • A predicate node is a node containing a condition

Any procedural design/ program can be translated into a flow graph. Later the flow graph can be analyzed for various paths within it.

Note that compound Boolean expressions at tests generate at least two predicate node and additional arcs.

Cyclomatic Complexity

The cyclomatic complexity gives a quantitative measure of the logical complexity. This value gives the number of independent paths in the basis set, and an upper bound for the number of tests to ensure that each statement is executed at least once.

An independent path is any path through a program that introduces at least one new set of processing statements or a new condition (i.e., a new edge)

From the example we can observe that:

  • Cyclomatic Complexity of 4 can be calculated as:

    1. Number of regions of flow graph, which is 4.

  • #Edges - #Nodes + 2, which is 11-9+2=4.

  • #Predicate Nodes + 1, which is 3+1=4.

The above complexity provides the upper bound on the number of tests cases to be generated or independent execution paths in the program.

Independent Paths:

    1. 1, 8

  • 1, 2, 3, 7b, 1, 8

  • 1, 2, 4, 5, 7a, 7b, 1, 8

  • 1, 2, 4, 6, 7a, 7b, 1, 8

Cyclomatic complexity provides upper bound for number of tests required to guarantee the coverage of all program statements.

Deriving Test Cases

Test cases are designed in many ways. The steps involved for test case design are:

  1. Using the design or code, draw the corresponding flow graph.

  2. Determine the cyclomatic complexity of the flow graph.

  3. Determine a basis set of independent paths.

  4. Prepare test cases that will force execution of each path in the basis set.

Note: some paths may only be able to be executed as part of another test.

Graph Matrices

Graph matrices can automate derivation of flow graph and determination of a set of basis paths. Software tools to do this can use a graph matrix. The graph matrix:

  • Is a square matrix with number of sides equal to number of nodes.

  • Rows and columns of the matrix correspond to the number of nodes in the flow graph.

  • Entries correspond to the edges.

The matrix can associate a number with each entry of the edge.

Use a value of 1 to calculate the cyclomatic complexity. The cyclomatic complexity is calculated as follows:

  • For each row, sum column values and subtract 1.

  • Sum these totals and add 1.

Which is 4.

Some other interesting link weight can be measured by the graph as:

  • 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

RELATED POST


INTEGRATION TESTING PART ONE

INTEGRATION TESTING PART TWO

INTEGRATION TESTING PART THREE

INTEGRATION TESTING PART FOUR

INTEGRATION TESTING PART FIVE

INTEGRATION TEST STANDARDS

INTEGRATION TEST STANDARDS PART TWO

QUALITY TESTING

QUALITY ASSURANCE

QUALITY ASSURANCE PART TWO

QUALITY ASSURANCE SQA

QUALITY OF DESIGN OF TEST CASE

QUALITY MANAGEMENT IN SOFTWARE TESTING

TOOLS FOR QUALITY MANAGEMENT

STATICAL QUALITY ASSURANCE

ISO APPROACH TO QUALITY TESTING

No comments:

Post a Comment