Glass Box Testing
A "glass box" testing method looks at the structure of the program and extracts test data from the logic and code of RAM. Precise box testing, open box testing, logic-driven testing, path-driven testing and structural testing are other terms for glass box testing.
Glass box testing's operational procedure
1. Input: The first inputs are Source code, design documents, functional specifications, and requirements.
2. Processing: Using risk analysis to guide at every stage of the procedure.
3. Appropriate test planning: creating test cases that thoroughly cover the code. Run rinse-repeat until the program is error-free. Furthermore, the outcomes are shared.
4. Output: Write the concluding report detailing all of the testing.
Techniques for testing
1. Statement coverage:
The goal of this technique is to go through each statement at least once. For this reason, every code line is tested. Every node in the flowchart has to be traversed at least once. This helps identify problematic code as each line of code is covered.
2. Branch Coverage:
Using this technique test cases are created so that there is at least one traversal of each branch from each decision point. All edges of the flowchart must be traversed at least once.
3. Condition Coverage:
As demonstrated in the example below, every condition in this technique must be covered.
READ X, Y.
IF X = 0 and Y = 0,
Print "0"
X = 0, Y = 55 for #TC1.
#TC2: Y = 0, X = 5.
4. Multiple Condition Coverage:
This method tests every possible combination of possible outcomes of situations one or more times. Think about this example for a moment:
READ X, Y
IF (X == 0 || Y == 0)
Print "0"
#TC1: X = 0 and Y = 0
#TC2: X = 0 and Y = 5
X = 55, Y = 0 in #TC3.
#TC4: 5 is Y, and 55 is X.
5. Basis Path testing:
This method creates flowcharts or control flow graphs from code. The number of independent paths is then determined by calculating cyclomatic complexity, which allows for creating the fewest possible test cases for each independent path.
Steps:
1. Create the related flow chart for control.
2. Determine the cyclic complexity.
3. Identify the separate routes.
4. Create test cases that go with each separate route.
5. In the flow graph, V(G) = P + 1, where P is the number of predicate nodes.
6. Given an edge count of E and a total node count of N, V(G) = E minus N + 2.
7. V(G) = the graph's total number of non-overlapping regions
8. #1, #2, #4, #P7, and #P8
9. #P2: 1-3; 5; 7; 8.
10. #P3: 1 – 2 – 3 – 6 – 7 – 8
11. #P4: 1 – 2 – 4 – 7 – 1 –... – 7 – 8
6. Loop Testing:
Loops are widely used and fundamental to many algorithms; hence, their testing is essential. Errors often occur at the beginnings and ends of loops.
- Simple loop testing: For simple loops of size n, test cases are designed that:
- Skip the loop entirely.
- Only one passes through the loop.
- 2 passes
- m passes, where m < n
- n-1 and n+1 passes
- Nested loops: We begin at the innermost loop in a nested loop, with all the loops set to their minimum count. Tests for simple loops are started with the innermost loop and progress outward until every loop has been tested.
- Loops that are joined together: separate loops that follow each other. Basic loop tests are conducted for everyone. Handle them as you would a nest if they aren't autonomous.
Characteristics of white box testing include
- Analysing an application's code coverage can help determine which parts of the code are not being tested. White box testing aids in this process.
- To conduct white box testing, which enables the testing of individual functions, methods, and modules, one must have access to the application's source code.
- Knowledge of programming languages: To comprehend the code structure and create tests, testers carrying out white box testing must be familiar with languages like Java, C++, Python, and PHP.
- Glass box testing helps locate logical errors in the code, such as improper conditional statements or infinite loops.
- Glass box testing is helpful in integration testing because it lets testers confirm that the various parts of an application are functioning as intended.
- Unit testing: Unit testing tests individual code units to ensure they function correctly. White box testing is another term for unit testing.
- Code optimisation: By finding any performance problems, duplicate code, or other areas that need improvement, white box testing can assist in code optimisation.
- White box testing can also be used for security testing since it enables testers to find any flaws in the application's code.
Glass Box Testing Benefits
- Makes test developers consider implementation carefully.
- Exposes "hidden" code errors.
- Detects problems with best programming practices, such as dead code.
Glass Box Testing Drawbacks
- It is costly since performing white box testing requires financial and time investments.
- There is a possibility that a few lines of code are missed accidentally.
- White box testing requires a deep understanding of the programming language.