Skip to content
BENIBIX Learn

White-Box Testing

Development🧪 Testing & QualityTest Practices

Also known as White Box Testing, Clear-Box Testing, Glass-Box Testing, Structural Testing

Testing a program while you read its code. Each path gets a test.

Think of it like

Think of it like a car with the hood up. The mechanic can see each part and test it.

Example

Jack sees a discount rule with three branches. He writes three tests, one for each, and coverage shows all three run.

Why it matters

It finds bugs on paths that users rarely reach but still matter.

Definition

White-box testing checks a program while looking at its code. The tester reads the code and writes tests for each path through it. If there is an if, they test the yes branch and the no branch. Unit tests are usually written this way. Test coverage tools show which lines the tests reached.
White box: the box is open, and each path inside gets a test.

Common mistake

Testing how the code works instead of what it does. Then any tidy-up breaks the tests.

Key takeaways

  1. 1
    Code open. The tester reads the code.
  2. 2
    Every path. One test for each branch.
  3. 3
    Coverage helps. See which lines ran.

Compare