Structural Testing : Introduction
-
The structure of a software product is responsible for designing test cases in order to test a software product.Since, the whole structure is known as structural testing, it is also known as white box testing.
-
Structural testing is more technical than functional testing as it attempts to design test cases from the source code and not from the specifications.
-
The major structural testing approaches are:
-
Statement Coverage: In this, the aim is to achieve 100% statement coverage i.e. each and every statement of program is executed.
-
Branch Coverage: In this, the aim is to achieve 100% branch coverage i.e. every branch either containing “true” or “false” conditions needs to be executed.
-
Path Coverage: This technique corresponds to test all possible paths i.e. it is a combination of branch and statement coverage techniques.
Structural Testing : Types
-
Structural testing can broadly be classified into four types. These are:
Structural Testing : Types
-
Control Flow testing
-
In this, various paths of programs and various test cases are designed to execute those paths which ultimately results in finding out the cyclomatic complexity of the programs.
-
Data Flow Testing
-
It is a technique used for determining improper use of data inside a software programs.
-
Incorrect variable declaration, Multiple times declaration and assigning values to variables can be some of the examples.
-
Slice Based Testing
-
Slicing a software program and testing those slices individually for defects and errors.
-
Mutation Testing
-
When small changes are made in some certain statements of source code to check whether the test cases are able to find the errors or not.
-
These changes are known as mutants.
-
The changes are very small such that they does not affect the overall objective of the program.
-
The goal of mutation testing is to assess the quality of test cases which should be powerful enough to fail the mutants in the code.
Structural Testing : Cyclomatic Complexity
-
The concept of cyclomatic complexity is used to find the number of independent paths present in a program graph.
-
There are three methods to calculate cyclomatic complexity. These are
If,
V(g) = Cyclomatic complexity.
n = Number of nodes.
e = Number of edges.
then,
-
V(g) = e-n+2
-
V(g) = Number of regions in the program graph.
-
V(g) = Number of predicate node + 1.
where, predicate node is the node with 2 outgoing edges.