Software Module Testing (Unit Testing)

In this article, we would discuss the concept of Software Module Testing or Unit Testing. We would look at the various techniques applied in Software Module Testing.

The following would be covered

1. Test approaches
2. Specification-Based Testing – Functional Testing
• Equivalence Partitioning
• Boundary-value Analysis
• Cause-effect Analysis
• Combinatorial Techniques
• Finite State Automaton-based Techniques
• Use-Case-based Testing
3. Structure-Based Testing
• Statement Coverage
• Decision Coverage
• Condition Coverage
• Condition/Decision Coverage
• Modified Condition/Decision Coverage
• Multiple Condition Coverage
• Basic Path Coverage

1. Test Approaches to Software Module Testing
Software Module testing could be carried out in one of two ways:
Specification based testing  where the system is considered a black box or a structure based testing where the system is viewed as a white box. Lets begin with the first one: Specification based testing.

2. Specification based Testing
Also called Functional Testing. Here, the system is considered as a black-box and only the external behavior of the system is known. The goal of the test is to check for the existence of the specified function and absence of unnecessary functions. It could be any of the following six ways:

a. Equivalence Partitioning
Data is partitioned into input and output equivalence classes and the data is expected to cover the same faults. Each equivalent class: represented by a test input. The test data should cover as much equivalence classes as posible.
Example of equivalence class is Triangle Program
Inputs: 3 integer values representing the length of the sides
Outputs: Equilateral, isosceles, scalene

b. Boundary Value Analysis
This approach examines the boundaries of data partitions such as upper and lower bounds.

c. Cause-effect Analysis
The approach examines the effect of the input(cause) on the outputs(effect)

d. Combinatorial techniques
Examines the combination of parameters. Could be ‘best quess’, ‘each choice’ or ‘n-wise’ testing.

e. Finite State Automata Based Techniques
In this case, the system is specified as a finite state machine. The objective here is the coverage of all states and all transitions

f. Use-case based Testing
Here, the test cases are derived from the specified use cases which are normally specified with preconditions and post-conditions.

3. Structure-Based Testing
Specification based testing  considers the system as a ‘white box’ where the internal structure of the system is also known. The objective of this approach is to cover the internal behaviour of the system usually by means of a graphical technique.
The approach is the examine the various components of the program structure:
Statement

• Block: Sequence of one or more statements
• Condition: Logical expression
• Decision: Outcome of logical operation
• Path: Sequence of statements from a starting point to an exit point

a. Statement Coverage
Defined as the (Number of executed statements during testing) divided by (Number of all the statements)

b. Decision Coverage
Defined as (Number of decision branches reached during testing) divided by (Total Number of Branches)

c. Condition Coverage
Defined as (Number of tested combinations of conditions) divided by (Number of aimed combinations of conditions)

d. Path Coverage
Defined as (Number of independent paths traversed during testing) divided by (Number of all independent paths)