Definition: White Box Testing is a technique where the tester has full knowledge of the internal code, structure, and logic of the program.
👉 Simple meaning: You test how the program works internally (code logic).
Requires programming knowledge
Tests internal structure
Also called:
Input → Code Logic → Output
↑
Tested here
👉 Focus is on code execution paths
Ensures that every line (statement) of code is executed at least once.
if (x > 0)
print("Positive");
👉 Test case:
Statement Coverage = (Executed Statements / Total Statements) × 100%
Ensures that each decision (true/false branch) is executed.
if (x > 0)
print("Positive");
else
print("Negative");
👉 Test cases:
Branch Coverage = (Executed Branches / Total Branches) × 100%
👉 🔥 Frequently asked!
Ensures that all possible execution paths in the program are tested.
if (x > 0)
print("Positive");
if (y > 0)
print("Y Positive");
👉 Possible paths:
👉 🔥 Very important for exams!
Tests the correctness of loops (for, while, do-while).
for(i=0; i<n; i++)
print(i);
👉 Test with:
Focuses on how variables are defined, used, and modified in the program.
int x = 5; // define
print(x); // use
Finds errors like:
Tests each individual condition in a decision.
if (x > 0 && y > 0)
👉 Conditions:
Test cases:
Statement < Branch < Condition < Path
👉 Path coverage is strongest.
✔ Define White Box Testing ✔ Statement vs Branch Coverage ✔ Path Coverage explanation ✔ Loop testing cases ✔ Coverage formulas ✔ Coverage hierarchy
| Technique | What it Tests | Key Idea |
|---|---|---|
| Statement Coverage | All lines | Each statement executed |
| Branch Coverage | Decisions | True/False paths |
| Path Coverage | All paths | Complete execution |
| Loop Testing | Loops | Iterations |
| Data Flow Testing | Variables | Define & use |
| Condition Coverage | Conditions | Each condition |
White Box Testing focuses on internal code logic
Requires programming knowledge
Key techniques:
Branch & Path coverage are most important for exams
Open this section to load past papers