Manual Testing

White Box Techniques

White Box Techniques

1. Data Flow Testing

Data flow testing is a technique for examining the data flow in a software. It is the process of gathering data on how the variables in the programme flow the data. It aims to acquire specific information on each stage of the process.

Data flow testing is a set of methodologies for examining a program's control flow in order to investigate the sequence of variables in relation to the sequence of events. Data flow may be checked by concentrating on both the points at which values are allocated to the variables and the points at which these values are utilised.

The control flow graph is used in data flow testing to uncover irrational items that can disrupt data flow. Anomalies in the flow of data are noticed when values and variables are associated because: 

  • The variables are used without being initialised.
  • If the variables that have been initialised are not used at least once.

2. Control Flow Testing

 

Control flow testing is a type of white box testing approach. The goal of this technique is to use a control structure to determine the execution order of statements or instructions in a programme. A test case for a programme is created using the control structure of the programme. The tester selects a specific component of a huge programme to set the testing path in this technique. Unit-testing is where it's most commonly employed. The control graph of the programme represents test cases.

To specify all possible execution paths, a Control Flow Graph is made up of nodes, edges, decision nodes, and junction nodes.

Notations castoff for Control Flow Graph

  1. Node
  2. Edge
  3. Decision Node
  4. Junction node

 

Node

A path of procedures is created by connecting nodes in the control flow graph. Essentially, it denotes the order in which processes will be performed so that the tester may establish the order in which procedures will be performed.

In the example below, the first node represents the start procedure, and the next procedure is to assign the value of n. After assigning the value, there is a decision node that determines the next node of procedure based on the value of n. If the value of n is 18 or greater, the Eligible procedure will run, otherwise the Not Eligible procedure will run. The junction node is the next node, and the stop node is the last node, which terminates the procedure.

Edge

The direction of nodes in a control flow graph is linked by an edge.

In the example below, all arrows are used to connect the nodes in the proper direction.

Node of decision

The decision node in the control flow graph is used to determine the procedure's next node based on the value.

As shown in the sample decision node, the value of n determines the next node of the procedure. If n is 18 or greater, the Eligible procedure is executed; alternatively, if n is less than 18, the Not Eligible procedure is executed.

Junction node

Junction node in control flow graph is the point where at the least 3links meet.

3. Branch Coverage

To cover all branches of the control flow graph, the branch coverage technique is utilised. It at least once covers all conceivable outcomes (true and false) of each decision point condition. The branch coverage approach is a whitebox testing technique that assures that each decision point's branches are all tested.

However, while branch coverage and decision coverage are fairly similar, there is a significant difference between the two. Branch testing covers all branches of each decision point of the code, whereas decision coverage covers all branches of each decision point of the code.

To put it another way, branch coverage is determined by the decision point and branch coverage edges.

It employs a control flow graph to calculate the number of branches, just like decision coverage

Let's understand it with an example:

  1. Read X  
  2. Read Y  
  3. IF X+Y > 100 THEN  
  4. Print "Large"  
  5. ENDIF  
  6. If X + Y<100 THEN  
  7. Print "Small"  
  8. ENDIF  

4. Testing Statement Coverage

One of the most common types of software-testing is statement coverage. It is subjected to white box testing.

White box test scenarios are created using the statement coverage technique. This method entails running all of the source code statements at least once. It is used to determine the total number of executed statements in the source code based on the total number of statements in the source code.

Under the white box testing process, which is based on the structure of the code, statement coverage generates scenarios of test cases.


 

The focus of white box testing is on the working of internal source code and the flow chart or flow graph of the code.

In general, there are a broad variety of elements in the internal source code, such as operators, methods, arrays, looping, control statements, exception handlers, and so on. Some code statements are executed and others are not depending on the input given to the application. The purpose of the statement coverage technique is to cover all of the code's potential executing statements and path lines.

5. Testing Decision Coverage

White box testing uses the decision coverage technique to give Boolean values decision coverage. This method displays the true and false results of Boolean expressions. When there is a chance of two or more outcomes from statements such as do while, if, and case (Control flow statements), it is referred to as a decision point since there are only two possible outcomes: true or false.

Using a control flow graph or chart, decision coverage covers all possible outcomes of each and every Boolean condition in the code.

In most cases, a decision point has two decision values: one is true and the other is false, which is why the total number of possibilities is usually two. Divide the number of exercised outcomes by the total number of outcomes and multiply by 100 to get the percent of decision coverage.

It's difficult to achieve 100% coverage with this method because expressions can be tricky at times. As a result, there are a variety of ways to report decision coverage. All of these strategies are quite similar to decision coverage in that they cover the most essential combinations. The benefit of these strategies is that they improve control flow sensitivity.