Introduction
White Box Testing is a type of testing in which the tester has a deep understanding of the system's inner workings or components under test, which Black Box Testing does not provide.
You should follow the below steps for doing the testing:
- Design all test scenarios, test cases and prioritize them according to high priority numbers. Test scenarios, test cases, and test data are the basis of any testing process. A good tester will design them as per business needs.
- Data must be provided for every test case and requirement. The tester can use this information to execute the test case and check the code's hidden areas, the time taken by various operations, etc.
- After this, testing of internal modules takes place. Methods and interfaces are internal modules that can handle all types of data appropriately or not.
- Tests will be conducted on control statements such as conditional statements and loops to ensure efficiency and accuracy.
- By examining how the code handles security, the last step of White Box Testing includes a security check to ensure all possible security loopholes are closed by looking at how the code handles security.
Must Read, Locators in Selenium
Techniques for White Box Testing
There are mainly three types of testing techniques:
Statement Coverage
This testing technique tests all the defined programming statements. This determines the number of explanations executed in the source code of an application.
There are two criteria:
1. What are the test requirements?
These are the statements in the program.
2. How to measure coverage?
Coverage = (Number of Statements Exercised / Total Number of Statements) x 100%
Example:
public class white_Box {
public static void main(String[] args) {
check(6, 4);
}
private static void check(int x, int y) { //Statement 1
if (x < y) { //Statement 2
System.out.println("x is less than y"); //Statement 3
} //Statement 4
else {
System.out.println("x is greater than y"); //Statement 5
} //Statement 6
}
}
Test Case 1: x=4, y=6; “When x is less than y”
Total number of statements = 6
Total number of executed statements = 4
Statement coverage= 4*100/6;
66.0 %
Test Case 2: x=8, y=3; “When x is greater than y”
//Total number of statements = 6
//Total number of executed statements = 5
//Statement coverage= 5*100/6;
//83.0 %
Branch Coverage
This type of testing technique tests all the defined programming statements.
Branch Testing = (Number of decisions outcomes tested / Total Number of decision Outcomes) x 100 %
Path 1:
No. of executed branches= 2
Total number of branches= 6
Branch Coverage = 2*100/6;
= 33.3%
Path 2:
No. of executed branches= 4
Total number of branches= 6
Branch Coverage = 4*100/6;
= 66.7%
Path Coverage
It is a testing technique corresponding to testing all possible paths, covering each statement and branch.
- 1=>2=>3
- 1=>4=>5=>6
- Therefore the path coverage is 2