What is White-Box Testing?
White-box testing (also called clear-box or structural testing) uses knowledge of the internal code and structure to design tests that exercise specific statements, branches, paths, and conditions.
Free to start · 7-day trial on paid plans
In depth.
Where black-box testing looks at behavior from the outside, white-box testing opens the box. Because you can see the code, you can target its structure and measure how thoroughly you exercised it through coverage criteria: statement coverage (every line run), branch coverage (every if/else direction taken), path coverage (every route through the code), and condition coverage (every boolean sub-expression evaluated both ways). Unit tests written by developers are the most common white-box testing.
Its strength is precision: you can find untested branches, dead code, and logic errors that behavior-only testing might miss, and you can prove a specific risky path is covered. Its weaknesses are that it requires programming skill and time, it is tied to the implementation (so refactors can break tests), and high code coverage does not guarantee correct behavior, you can cover every line and still miss a requirement.
White-box and black-box are complementary. The mature view, and the interview-winning one, is that you use white-box for thoroughness at the unit level and black-box for behavior and requirements at higher levels, with gray-box blending the two.
Why interviewers ask about this.
Interviewers use white-box questions to probe whether you understand coverage metrics and their limits, especially that high coverage is necessary but not sufficient for quality.
Example scenario.
A developer writing unit tests sees an error-handling branch that no test exercises (branch coverage flags it). They add a test that forces the failure path and discover the catch block swallows the exception silently, a bug invisible to black-box tests that never triggered that branch.
Interview tip.
Name the coverage types (statement, branch, path, condition) and make the key point that high coverage does not equal correctness, you can cover every line and still miss a requirement. That nuance separates strong candidates.
Frequently asked questions.
What are the types of code coverage in white-box testing?
Statement coverage (every line executed), branch coverage (every decision direction taken), path coverage (every route through the code), and condition coverage (every boolean sub-expression evaluated both ways).
Does 100% code coverage mean the code is bug-free?
No. Coverage proves lines or branches were executed, not that the behavior is correct or that requirements are met. It is necessary for thoroughness but not sufficient for quality.
Related Terms
Explore related glossary terms to deepen your understanding.
Related Resources
Dive deeper with these related interview prep pages.
Free QA career tools, no account needed
Instant and private, everything runs in your browser. Try them before you sign up.
QA Resume Checker
Instant 0-100 score on automation keywords, impact, and ATS formatting.
QA Cover Letter Generator
A tailored 3-paragraph QA cover letter from your resume and a job post.
QA Application Tracker
Drag-and-drop kanban to track every QA application from Applied to Offer.
QA Take-Home Test Generator
A realistic take-home assignment with a scenario, tasks, and a rubric.
QA LinkedIn Headline Generator
A recruiter-searchable headline, About section, and skills list.
QA STAR Story Builder
Structure a QA behavioral answer with the STAR method and instant checks.
QA Bug Report Generator
Build a clean, reproducible bug report for Markdown, Jira, or plain text.
Boundary Value Analysis Generator
Generate boundary value and equivalence partitioning test cases from a range.
QA Metrics Calculator
Calculate DRE, defect leakage, defect density, and pass rate with interpretation.
QA Test Plan Generator
Build a structured test plan (scope, approach, criteria, risks) in Markdown.
Ready to Ace Your QA Interview?
Practice explaining white-box testing and other key concepts with our AI interviewer.
Join 1,200+ QA engineers already practicing with AssertHired.
Start your free QA interview