Black, white and grey box testing

The three methods describe how much you know about the code while you test. Most QA work is black box, but knowing a little about the inside helps you find bugs faster.

At a glance

Method You know Usually done by Typical example
Black box Only inputs and outputs QA, product, users Sign in with a valid and an invalid password
Grey box Some internals: API, database, logs QA Create an order in the app, then check the API response and the stored record
White box The source code Developers Unit tests that cover every branch of a function

Black box testing

You treat the app as a closed box. You give it input, watch what comes out and compare it with the requirements. You don't need to read any code.

Requirement: a coupon code gives 10% off orders over $50.

Test: order of $60 + code SAVE10  -> total $54.00
Test: order of $40 + code SAVE10  -> error "Order must be over $50"
Test: order of $60 + code save10  -> is the code case-sensitive? Check the spec.

White box testing

You read the code and design tests that exercise its paths: every if, every loop, every error handler. This is mostly what unit tests do.

Coverage terms you will hear

Coverage is not quality100% line coverage only means every line ran. It doesn't mean the results were checked, or that the requirements were right.

Grey box testing

You test from the outside like a user, but you use what you know about the inside to pick better tests and check results more closely. This is where QA adds the most value.

Test: change the profile name to "Ana Lúcia"
UI:      new name shows on the profile screen
Network: PUT /profile returns 200 with the new name
Logs:    no warnings about encoding
Reload:  name is still correct after closing and reopening the app

To get started, see Network debugging, Storage and cookies and Platform tools & ADB.

Which one to use