What are black box, white box and grey box?
Black box designs tests from requirements, white box from the code's internal structure, and grey box adds knowledge of the API, database and logs. In ISTQB black and white box differ by the basis of the tests, not by what the tester knows. Grey box sees consequences beyond the UI, such as a duplicate database record, but expected results still come from requirements.
QA Fundamentals · Types of testing
The UI says "Success" after a transfer. But did the record really reach the database?
A tester clicks "Transfer", sees a green message, the balance updates, and marks the case "passed". In reality the user clicked the button twice, and the database holds two identical transfers: the interface showed only the last one. A check based only on the message on screen would not reveal this. The lesson covers three approaches to testing defined by what you know about the system's insides, and when each gives an answer the others do not.
How it works and why. Black box: tests are designed from requirements and only input and output are observed, without looking inside. Equivalence classes, boundary values and decision tables belong here. White box: tests are designed from the internal structure (branches, conditions, loops) and the amount of executed code is measured. Usually this is developers' work at the component level. Grey box: the middle ground, where the tester does not read code but knows the database schema, API contracts and logs and uses them to invent checks and to see the consequences of actions beyond the UI.
In ISTQB black-box and white-box differ not by what the tester knows but by the basis of the tests: the specification or the internal structure. "Grey box" is not a separate term there, but it is common in practice and in interviews. The third group of techniques in ISTQB is experience-based techniques (error guessing, exploratory testing, checklists).
What each approach sees
Why all three are needed: each catches what the others miss. Black box finds behaviour that does not match requirements, including a missing feature that is not in the code and therefore invisible to any coverage. White box finds code nobody ran and dead branches but does not know the requirement was different. Grey box sees the hidden consequence: a double record, an invalid status, a missing event.
Example: one action, three views. Black box: the tester clicks "Transfer", sees success and the new balance. Conclusion: "works". Grey box: the tester opens DevTools, sees two POST /transfers with 201 in Network and checks the database:
SELECT id, status, amount
FROM transfers
WHERE account_from = 1042
ORDER BY created_at DESC
LIMIT 5;
-- illustrative result
id | status | amount
9071 | completed | 100.00
9070 | completed | 100.00 <- the same transfer twice
Now the bug is visible: there is no protection against a repeated request (a disabled button, idempotency). Black box would notice the duplicate only by carefully reconciling the balance and history, while Network and the database show both the duplicate and its cause at once. White box, in turn, looks at code level at whether all branches of such a function are covered:
function fee(amount: number) {
if (amount <= 0) throw new Error('bad amount');
if (amount > 10_000) return amount * 0.02;
return amount * 0.01;
}
To execute every branch at least three tests are needed: amount ≤ 0, amount above 10,000 and an ordinary one. Branch coverage is the share of branches executed by such a set, and it shows where tests have never been.
Limits and alternatives. One hundred percent code coverage does not mean no bugs: it shows a line was executed but not that the expected result is right, and it does not see missing requirements or data-dependent and integration defects. Black box does not know which parts of the code were never exercised. Grey box depends on access and knowledge: "I partly know" has no clear border. There is a bias risk too: when a tester reads the implementation, they tend to check what the code does rather than what it should do by requirements. So the expected result comes from the requirements, not from the code.
Common mistakes.
- Equating black box with manual and white box with automation: it is about the source of tests, not whether they are manual.
- Trusting only the UI: a "Success" toast does not mean a correct record, event or email.
- Preparing data by writing straight into the database and bypassing validation: states appear that are impossible in the product, and "bugs" follow from them.
- Taking the expected result from the code: the test only confirms the implementation.
- Chasing 100% coverage as a goal: it is an indicator of gaps, not of quality.
Check yourself
After saving a profile the UI says "Saved", but after a page refresh the old data is back. How does grey box help narrow the search?
Answer
In DevTools I look at the save request: whether it was sent, its status and body. If there was no request, or a 4xx that the interface swallowed, it is the front end. If it was 200 and the database or the next GET still holds old data, it is the back end. One look at the network and the record rules out half of the hypotheses.
A test set gives 100% branch coverage. Can the function be considered tested?
Answer
No. Coverage shows the code was executed, not that the result is right. It does not see requirements that are absent from the code, wrong expected values, data-dependent and integration defects. Tests from requirements (black box) are needed too.