Skip to content
Figure 1Black-box and white-box testing: what each can see
Black-box and white-box testing: what each can seeBlack boxinputs, outputs, requirementspartitions, boundaries, state tablesno view of the codefinds missing behaviourWhite boxstatements, branches, paths, conditionscoverage measured by toolsneeds the code and the buildfinds untested logicgrey box
Black-box and white-box testing see different things. Grey box borrows from both.

Black box vs white box testing: what each finds and misses

Black-box testing judges the software from outside, against what it is supposed to do. White-box testing judges it from inside, against what the code actually does. Neither finds everything, and the useful question is not which is better but which one is cheaper for the defect you are hunting.

Quick answer

Black-box testing derives tests from requirements and observed behavior without reading the code; white-box testing derives them from code structure (statements, branches, paths). Black box finds missing and wrong features; white box finds untested logic and dead paths. Most teams use black box at system and acceptance levels, white box at unit and integration levels, grey box between.

Key figures

Black-box basis
requirements, inputs, outputs
White-box basis
statements, branches, paths
Typical white-box levels
unit, component, integration
Typical black-box levels
system, acceptance
Illustrative yield
4.2 vs 2.6 defects per hour, by class
Grey box
design knowledge, no line-level view

The comparison in one table

The two approaches differ on where the test ideas come from, not on whether the tests are automated or manual, and not on who is allowed to run them. A developer who writes a test from a user story is doing black-box testing. A tester who reads a stack trace and targets the branch that threw it is doing white-box testing. The table below sets the two side by side on the six dimensions that matter when you plan a test effort.

Black box and white box compared on six planning dimensions.
DimensionBlack boxWhite box
Basis for test designRequirements, specifications, user stories, observed behaviorSource code, control flow, data flow, design documents
Who usually does itTesters, business analysts, product owners, pilot usersDevelopers, test engineers with code and build access
What it findsMissing features, wrong behavior, misread requirements, integration and usability faultsUntested branches, dead code, wrong loop bounds, unhandled exception paths, off-by-one logic
What it missesLogic that no requirement mentions, unreachable code, silent internal error handlingRequirements that were never coded, a wrong interpretation implemented correctly
Typical levelsSystem, acceptance, some integrationUnit, component, integration
Cost profileCheap to design, costly to run (needs a deployed system and data)Needs code skill and a build, then very cheap and fast to run repeatedly
Coverage measureRequirements covered, partitions coveredStatement, branch, condition, path coverage

What black-box testing finds, with examples

Black-box tests start from a statement of intent. An order total should apply a 10 percent discount above 100 units; a date field should reject February 30; five failed logins should lock the account for 15 minutes. The tester never looks at how any of that was coded. That blindness is the strength: a black-box tester reads the discount rule and asks what happens at exactly 100 units, at 99, at 101, and at 100 units spread across two lines. If the developer implemented quantity > 100 where the business meant quantity >= 100, the test at 100 catches it, and no amount of code reading would have, because the code is internally consistent.

The design techniques are the familiar ones: equivalence partitioning and boundary value analysis, decision tables, state transition testing, use case testing and pairwise combination. Each one is a systematic way to sample the input space without seeing the implementation. Black box is also the only approach that catches a feature that was simply never built. A requirement with no code behind it has zero branches to cover, so a coverage tool will never flag it.

What white-box testing finds, with examples

White-box tests start from the code. Take a function that loads a customer, checks for a null record, then loops over the customer's addresses to pick the default. A black-box tester might never create a customer with zero addresses, because the user interface always adds one. The white-box tester sees the loop, sees that it indexes from 1 rather than 0, and writes the test that proves the last address is skipped. The same tester sees a catch block that logs and continues, and writes the test that forces the exception, which is how you learn the function returns a partial object instead of failing.

White-box coverage is measurable, which is its second strength. You can ask for every statement, every branch, every condition outcome, and at the highest level every independent path, and a tool tells you what is still dark. The catch is that 100 percent branch coverage proves only that every branch ran once, not that it did the right thing. Test coverage covers what those percentages do and do not mean.

Grey-box testing: the practical middle

Almost every experienced tester works in grey box. You do not read every line, but you know the architecture, you can read the database schema, you have the API contract, and you can see the logs. That knowledge shapes better black-box tests: if you know there is a cache in front of the pricing service, you test with a stale cache. Grey-box practices worth naming:

  • Reading the interface contract or schema before designing input partitions, so the partitions match the real data types and lengths.
  • Using logs, traces and database state as test oracles, not just the screen.
  • Asking the developer which branches worry them, then designing external tests that reach those branches.
  • Reviewing the coverage report from unit tests to decide where system-level exploratory time is best spent.

The cost-effectiveness question

Which approach finds more defects per hour? The honest answer is that it depends on the defect class, and the illustrative table below is a way to think about it, not a measurement of your product. Boundary and logic faults inside a function are cheap for white box because the test runs in milliseconds and the tester can see the exact edge. Missing features and misunderstood requirements are nearly free for black box and nearly impossible for white box. Integration faults sit in the middle and usually favor black-box tests at the API level.

Illustrative defects found per tester hour by defect class. Numbers are for reasoning, not benchmarking.
Defect classBlack box, defects per hourWhite box, defects per hourCheaper approach
Missing or misread requirement3.00.2Black box
Boundary error inside a function1.54.0White box
Unhandled exception path0.43.5White box
Integration or contract mismatch2.51.0Black box (API level)
Usability or workflow fault2.00.0Black box
Dead code or unreachable branch0.02.0White box
Weighted total for a typical mix4.22.6Depends on the mix

One issue of the original magazine was, as far as the archive record shows, cited by a research repository for a study comparing black-box and white-box test cost-effectiveness and coverage on an open source program; the issue index lists what survives. The general finding of that line of research, repeated in several academic studies since, is that the two approaches find largely different defect sets, so the combination is worth far more than either alone. If you must pick one for a fixed budget, pick by the defect class you fear most, which is what risk-based testing gives you a method for.

Rule of thumb

Use white box where the logic is dense and the cost of a wrong branch is high (pricing, permissions, calculations). Use black box where the risk is that the team built the wrong thing. Never report either coverage number without the other beside it.

Which to use when

  • New feature, unclear requirements: black box first, at the API and screen, to find the misunderstanding before it is coded in three places.
  • Calculation engines, rules, state machines: white box at the unit level with branch coverage, then black-box decision tables at the system level.
  • Legacy code with no tests: black-box characterization tests to pin down current behavior, then white box once you can read what the code does.
  • Third-party or vendor components: black box only, because you have no code; treat the contract as the specification.
  • Security and error handling: white box for exception paths and input validation, black box for abuse cases the code never considered.
  • Regression suites: mostly white box at unit level for speed, a thin black-box layer at the top, which is the shape of the test automation pyramid.

Common questions

Is black-box testing the same as manual testing?

No. Both approaches can be manual or automated. An automated API test written from the specification is black box; a manual test that steps through the debugger is white box.

Can a developer do black-box testing on their own code?

Yes, but it is harder, because they know how it was built and unconsciously avoid the paths they did not implement. Pairing with a tester or swapping features between developers helps.

Does grey-box testing have its own techniques?

Not really. It uses black-box design techniques informed by architectural knowledge, plus white-box coverage data to direct effort. It is a stance more than a technique set.

Which approach does ISTQB recommend?

The ISTQB syllabus treats black-box, white-box and experience-based techniques as complementary and expects a tester to know all three. It does not rank them.

What does structural versus behavioral testing mean?

Structural is another name for white box (tests derived from the structure of the code). Behavioral is another name for black box (tests derived from expected behavior). The terms are interchangeable in most standards.

How do I explain the difference to a project manager?

Black box checks that we built the right thing. White box checks that we built the thing right. You need both, and they find different bugs.

Sources

  1. ISO/IEC/IEEE 29119-4:2021, Software testing, Part 4: Test techniques
  2. ISTQB Certified Tester Foundation Level (CTFL) v4.0 syllabus and overview
  3. Hayhurst et al., A Practical Tutorial on Modified Condition/Decision Coverage, NASA/TM-2001-210876

Further reading named in the text

  • Glenford J. Myers, Corey Sandler, Tom Badgett, The Art of Software Testing, 3rd edition (Wiley, 2011)
  • Boris Beizer, Software Testing Techniques, 2nd edition (Van Nostrand Reinhold, 1990)
  • Lee Copeland, A Practitioner's Guide to Software Test Design (Artech House, 2004)

This guide is part of the software testing techniques hub. It is best read alongside equivalence partitioning and boundary values and test coverage, which cover the neighbouring questions.