We use analytics to count visits and form use. It is on unless you reject it. We show no ads on this site.

Glossary

White box testing

Published . Last updated . Published by Zapple.Tech, founded by the founders of CodeceptJS and Codeception, open-source testing frameworks.

Also called
white-box testing, structural testing, glass box testing, clear box testing
Published
Updated
Definition

White box testing designs tests from the internal structure of the code, so you can check that its statements and branches actually run. It suits developers and the code you control. It shows which code no test has touched, but it cannot show that the code does what users need, or that a tested line is tested well.

What do the white box coverage measures count?

The ISTQB syllabus says white-box testing “is structure-based and derives tests from the system’s implementation or internal structure (e.g., code, architecture, work-flows, and data flows)”. NIST words it from the assessor’s side: a methodology that “assumes explicit and substantial knowledge of the internal structure and implementation detail of the assessment object”. The coverage measures below say how much of that structure your tests touched.

Measure What it counts What it misses Tool example
Statement Statements the tests executed An if that was never false still counts as covered coverage.py; JaCoCo counts lines and instructions
Branch Branches the tests executed Defects that need a specific path through the code JaCoCo branches, coverage.py

The syllabus says that branch coverage subsumes statement coverage, and that 100% statement coverage does not ensure all the decision logic has been tested. Coverage.py shows the gap between the two: statement coverage can mark every line of a function as executed while the if was never evaluated as false, which only branch coverage flags as a “partial branch”.

White box testing: tests are chosen from the structure of the code; a test that runs every line of a decision but never takes its false branch counts as full statement coverage, while branch coverage shows the untested branch

How is white box testing different from static testing?

The two answer different questions. White box testing names what the tests are designed from: the code’s structure. Static testing names how the check is done: without running the code, through reviews and analysis tools. The ISTQB syllabus notes that white-box techniques can also be used in static testing, for example in dry runs of code. Our AI code review checklist is an example of static testing.

Who should do white box testing: developers or a QA team?

The ISTQB foundation syllabus names no role for white-box testing. This is our judgement from practice.

  • Developers should own it for code they write. They can see the structure and fix the gap in the same change. Unit tests written with test-driven development give you coverage as a side effect, in our experience.
  • A QA team adds most when it reads coverage reports as a map of risk, asks why a critical module has gaps and checks that tests assert something. Microsoft’s Azure Well-Architected testing guidance says to “Generate coverage reports to identify gaps in automation.” We would not ask testers to write white box tests for code they cannot read.
  • An outside reviewer helps when nobody on the team trusts the numbers. A QA audit and assessment looks at your tests, pipeline and release process and reports what is at risk and what to fix first.

For tools, see our list of unit automation testing tools.

What coverage figure is worth asking for, and what does a high figure not tell you?

We do not recommend one percentage for every product. Ask for these instead.

  1. Coverage on the code that matters. A figure for the payment module says more than one for the whole repository.
  2. Branch coverage, not only statement coverage. The coverage.py example above shows why.
  3. No drop on a change. A rule that coverage may not fall on a pull request is easier to keep than a target.
  4. Assertions that can fail. A test that runs a line without checking a result raises coverage and proves nothing. Mutation testing checks for this by changing the code and seeing whether tests notice.

A high figure says the lines ran. It does not say the behavior is right, that requirements are met, or that missing features exist. Pair it with black box testing and our guide to automating white and black box tests with Selenium.

What does Zapple.Tech do about it?

If you do not know whether your coverage figure means anything, start with the evidence. Zapple.Tech starts with a one-week QA audit of one product area. It looks at its tests, pipeline and release process, and ends in a written report on what is at risk and what to fix first, plus a pilot plan you can run with Zapple.Tech or without it. Read more on the QA audit and assessment page. Tell us about your product in the form below.

  • Mutation testing

    Mutation testing measures how good a test suite is by making small deliberate changes, called mutants, to the code and running the tests against each one. A failing test kills the mutant; a surviving mutant marks behavior the tests do not check. Unlike code coverage, the mutation score shows whether tests would notice a change, not only which lines ran.

  • Test-driven development

    Test-driven development (TDD) is a programming workflow in which a developer turns one planned scenario into a failing automated test, writes just enough code to make it pass, optionally refactors, and repeats until the test list is empty. The tests direct the design of the code, so TDD is a way of writing code, not a test phase run afterwards.

  • Black box testing

    Black box testing checks what software does against its specification, without looking at the code. You give it inputs and compare the outputs with what the requirements say. It suits system and acceptance checks and works for outside teams, but it cannot show you which parts of the code no test has run.

All terms in the glossary

QA audit

QA audit and assessment

QA audit services: a one-week review of your tests, pipeline and release process, with a written report on what is at risk and what to fix first.

See the service

Questions about white box testing

What is white box testing?

The ISTQB syllabus says white-box testing is structure-based and derives tests from the system's implementation or internal structure, such as code, architecture, work-flows and data flows. The tester uses the code and its branches to decide which tests to write, and a coverage tool reports which parts the tests reached.

What is the difference between white box and black box testing?

White box testing designs tests from the internal structure of the code. Black box testing designs them from the specification or the behavior, without looking inside. White box finds code that no test reaches. Black box finds behavior that does not match what was asked for. They answer different questions, so you can use both.

What are the white box testing techniques?

The ISTQB foundation syllabus covers two, statement testing and branch testing. It says the more rigorous techniques are not discussed in it. Each is measured by a coverage figure for the part of the structure that tests have exercised. Mutation testing is a related check that changes the code to see whether the tests notice.

Is unit testing white box testing?

In our judgement, often, but not always. A unit test is white box when its author picks the cases from the code's structure, for example to reach each branch. A unit test that checks only the public behavior of a function, without regard to its internals, is closer to black box.

Request a QA audit quote

Tell us what you ship and what worries you.

What happens after you send this

  1. You send the form: your situation and what you need tested, then your name and work email.
  2. Within one business day, we reply with a suggested first step, its scope, timeline and a quote.
  • Fixed scope
  • You decide after each step
  • The tests live in your repository
  • An NDA signed before access

“They helped us to close the positions and consult our team how to proceed further. High-quality quick feedbacks with the deep checking of the required tasks, professional approach, great understanding of the company's technologies and product, detailed reports.”

Kristina Lavrentieva, Manager at keepgo.com, Israel
  • Rated 4.9 out of 5 on Clutch, from 7 client reviews
  • 42 completed test automation and infrastructure projects
  • Founded by the founders of CodeceptJS and Codeception, open-source testing frameworks

Request a QA audit quote

    What is closest to your situation?
    Optional. The product, the platforms, how often you release, what broke last.

    You decide after our reply whether to go ahead.

    Prefer to talk first? Book a call

    One-week QA audit · written report

    Request a QA audit quote