9: Types of Testing - Part 3

White Box Testing

We won’t be covering much of it; as most of it is done by the developer.

Testing based on an analysis of the internal structure of the component or system. Also known as glass box testing.

1.   In white box testing, the structure of the program is taken into consideration.

  1. The objective is to ensure that each and every line of the code is tested.
  2. Testing the product based on the internal system knowledge.
   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

Notation for representing control flow


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.

Any procedural design can be translated into a flow graph.

Example:

Cyclomatic Complexity


Complexity of the module.

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 and both sides of every condition are executed at least once.

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


Cyclomatic Complexity of a given graph G {V(G) = M }= #Edges - #Nodes +  2

V (G) = M = e – n + 2

Identification of Basis Path:

For Identification of Basis Path independent path is required.

Independent Path:

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

  • Independent Paths:
    1. 1, 8
    2. 1, 2, 3, 7b, 1, 8
    3. 1, 2, 4, 5, 7a, 7b, 1, 8
    4. 1, 2, 4, 6, 7a, 7b, 1, 8

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

Deriving Test Cases


  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.

CONTROL STRUCTURE TESTING

 
Condition Testing

Condition testing is a test case design method that exercises the logical conditions contained in a program module. The condition testing method focuses on testing each condition in the program.

 

Relational Operator

Error in the usage of operator

A relational expression takes the form E1 <relational-operator> E2

Where E1 and E2 are arithmetic expressions and <relational-operator> is one of the following: <, ≤, =, ≠ (none quality), >, or ≥. A compound condition is composed of two or more simple conditions, Boolean operators, and parentheses.


Boolean Operator Testing

Error in the usage of operator

Boolean operators allowed in a compound condition include OR (|), AND (&) and NOT

(¬).A condition without relational expressions is referred to as a Boolean expression.
 

  Loop Testing(Pressman)

Error in its usage.

 

Loops are the cornerstone for the vast majority of all algorithms implemented in software. And yet, we often pay them little heed while conducting software tests.

Loop testing focuses exclusively on the validity of loop constructs. Four different classes of loops can be defined: simple loops, concatenated loops, nested loops, and unstructured loops.

Complex loop structures are another hiding place for defects. It’s well worth spending time designing tests that fully exercise loop structures.

Looping are executed for0,1, 2. n, n-1,n+1

 
Simple loops

0th Iteration

1st Iteration

2nd Iteration

Kth Intearion

K<N Intearion

(n-1)th Intearion

(n+1)th Intearion

N is the termination point.

 

Nested Loops moves from the inner most to the outer most. Each nested loop is treated as simple loop

 
Concatenated loops Check for the interdependency

No comments:

Post a Comment