Skip to main content
Testing Fundamentals
DEFINITION

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

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 IT MATTERS

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

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.

TIP

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.

FAQ

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 Resources

Dive deeper with these related interview prep pages.

FREE TOOLS  /  no signup

Free QA career tools, no account needed

Instant and private, everything runs in your browser. Try them before you sign up.

EXEC.NOW

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
FREE.TO.START  ·  7.DAY.TRIAL ON PAID PLANS
Written by Aston Cook, Senior QA EngineerLast updated May 2026