Updated April 12, 2023
Introduction to Control Flow Testing
Control flow testing is a software testing technique that uses the control flow technique and it is represented as white box testing. Control flow testing is a testing strategy in a structured manner that depicts the execution order of the statements or instructions given. It is used to develop test cases of a program, where the tester selects a large portion of the program to test and to set the testing path. The whole test cases are represented in the form of a control flow graph like node, edge, and are mostly used in unit testing.
Uses of Control Flow Testing
Control flow testing is one of the white box testing approaches that go through a series of program codes and executes the test cases and another approach is to execute data flow.
There are various uses of control flow testing which I am going to discuss now:
- Control flow testing is used for unit testing purposes whose approach is to identify the execution path and depending upon those paths unit cases are written for that and execution is done using program codes.
- Control flow graphs are created through testing purposes that represents the overall flow of the program, the paths through analysis can be done and various test cases that emerge out from the paths.
- The control flow graph through testing covers every node and edge of the graph that helps in satisfying the structured data in testing purpose and guarantees proper testing code coverage.
Explain the Notation of Control Flow Testing
Four nodes are used in control flow testing. They are:
1. Node: In the control flow graph, nodes play an important role in creating a path of procedures. The nodes help in representing the sequence of procedures or statements and the order in which it should come. The sequence of order of instructions can be known through the help of the testing team.
In the control flow graph, the nodes represent the set of program statements. There are overall five different types of nodes and in a graph, there is an entry node as well as an exit node.
This is a control flow graph diagram.
In this diagram, we can see that there is a starting/entry node of the graph. The next process is to assign the nth value and after that, the decision node will have the responsibility to decide the next process whether the value of n is greater than or less than 18. If the value of n is greater or equal to 18 then the process will execute as eligible and if the value of n is less than 18 then the process will execute as non-eligible. In the end, it will pass on to the junction node that is the last node to stop the entire process.
2. Edge: In the control flow graph, an edge is represented as direction arrows in which the nodes are connected to which nodes.
The edge is responsible for connecting the first node until the end node. In the above diagram, it is visible where the arrows are going in linking the nodes and in what direction.
3. Decision Node: In the control flow graph, the decision node is one of the most important forms of the node that depicts at which node the process will follow depending upon conditional values.
It is a conditional statement that creates two or more control statements like if or switch statements. In the above example, the decision node takes care of the process that will go next depending upon the value of n. If the value of n is greater than or equal to 18 then the eligible process will execute, otherwise, if the value is less than 18, then the non-eligible process will execute.
4. Junction node: In a control flow graph, the junction node is the point where at least three nodes meet.
Advantages and Disadvantages of Control Flow testing
The advantages and disadvantages are as follows:
Advantages
Below are the advantages;
- It is a unit testing that uses control flow graphs, pointing as nodes and edges that represent sequences of procedures to execute.
- In unit testing, major defects can occur. But with the help of testing all the major and minor defects are thoroughly analyzed and tested during the testing phase by the testers and more than half of the defects are determined using it.
- The control flow testing is also responsible for determining at least one-third of the overall defect in the entire program that helps in analyzing and doing the test cases better.
- The testing can be done both manually or in a fully automated manner since the control flow graph that represents the sequence of instructions to be executed can be done by using hand i.e. in manual mode and also can be achieved by using software applications i.e. in a fully automated manner.
- The testing is represented using paths that cover all the nodes and edges, satisfy the overall testing criteria resulting in optimizing the test coverage of the program.
Disadvantages
The disadvantages are:
- The missing paths is very difficult to find in the entire control flow graph if the graph is huge in size and the entire program and model are controlled by the same person.
- It is not able to catch all the mistakes during the instantiation of a variable.
- The mistakes caught during specification cannot be caught all the time during testing.
- Any mistakes or mismatches, if happen, in the interface is very difficult to catch during testing.
- It was also unable to focus on the links where a variable got the value and where the values are exactly used.
Conclusion
The control flow testing has been the greatest approach for any unit testing purposes, with the help of control flow graph, it can provide all the valuable information in solving and executing instructions based on conditions given and making it easy using loop statements.
Recommended Articles
This is a guide to Control Flow Testing. Here we discuss the uses of Control Flow Testing along with the advantage and disadvantages. You may also look at the following articles to learn more –