Source: https://everyrole.dev/blog/black-box-vs-white-box-testing

# Black box vs white box testing, with real examples

Black box vs white box testing on one small app. What each finds, what each misses, with the real answers the app gave, and when to use which.

Nov 22, 2026  6 min read  by the EveryRole team

Black box vs white box testing comes down to where you stand. A black box test uses the app the way a person does, through the browser, and knows nothing about the code. A white box test is written by someone reading the code, and it aims at lines, branches and functions. Each one finds bugs the other can’t see, so the useful question is which bugs you are after today.

The definitions are everywhere. What is harder to find is the same app tested both ways. So here is ours.

![Two cards. Black box testing, from outside, finds a server answer with no form and a viewer refused at the form's address, and misses that the name is trimmed before it is counted. White box testing, from inside, finds the trimming line and the owner condition, and misses what the page looks like when the condition says no.](https://everyrole.dev/s/blog/black-box-vs-white-box-testing/outside-inside.webp)

One practice app, two sides. Every line in the picture is something that app really does.

## What is black box testing, on a real app

Our practice app has items. An editor logs in, opens “New item”, types a name of at most 60 characters and a note, and presses “Create”. A viewer can see the list and nothing else.

Testing it as a black box means we open a browser and never open the code. In an afternoon that gave us these (two of them with the browser’s developer tools open, to send a request past the form):

- **The server’s own answer to an empty name is a dead end.** The browser stops an empty form first. Sent past the browser, the server answers with a page that says “A name of 1 to 60 characters, please” and has no form on it. Whatever was typed in the note is gone. (The full story is in [the empty form post](https://everyrole.dev/blog/empty-form-test).)
- **A viewer’s button is disabled, and the address is closed too.** The viewer’s “New item” is greyed out. Typing `/items/new` in the address bar answers “Viewers can’t create items.” Both had to be tried, because a disabled button says nothing about the address behind it.
- **Another editor’s item answers “There is no such page.”** We logged in as a second editor and opened the first editor’s item by its address. Not found. Good.
- **The set-up wizard’s team size is checked by the browser only.** The field refuses letters. Sent past the form, the server saves the word “lots” and the summary page shows it.

All of it is what a real person, a careless script or a curious user would meet.

## Black box testing examples that code review won’t give you

Look at what those four have in common. Each one is an answer: a page, a message, a button state. Code can be correct line by line and still answer badly. The owner check in our practice app is one condition, and a reviewer would approve it. It takes a second account and a browser to learn that the refusal is a clean not-found page with a link back, and to learn it again after the next deploy.

Black box tests also survive rewrites. If we rebuilt the app in another language tomorrow, every case above would still be valid, because none of them mentions how the app is made. That is why [a test case](https://everyrole.dev/blog/how-to-write-test-cases) written from outside is one input and one expected result on the page, and nothing about functions.

## What white box testing sees that the outside can’t

Now open the code. Within a minute we found something the afternoon of clicking missed: before the server counts the name’s characters, it trims the spaces from both ends. A name of 59 letters and a trailing space is saved as 59. From outside you find that only if you happen to type a space in the right place. (We did, by accident, while writing about [boundary values](https://everyrole.dev/blog/boundary-value-testing).)

That is what white box testing is for:

- **Branches nobody reaches by clicking.** The code that handles a missing field, a negative number, a second request arriving during the first. A unit test can call each branch directly.
- **Rules that are hard to hit from outside.** Rounding, time zones, the trim above. You see the rule in one line and write the three inputs that pin it down.
- **Speed.** A unit test runs in milliseconds and points at the function that broke. A browser test points at a page and leaves the rest to you.

And its blind spot is the mirror image. A white box test passes when the function returns what the author expected. It says nothing about whether the button that calls the function is on the page, enabled, and wired to it. That is one of the ways [tests pass while the app is broken](https://everyrole.dev/blog/hollow-passes).

## Black box testing techniques worth knowing

The textbooks list many. For a web app, we use four and skip the rest:

1. **One good input and one wrong one per kind of field.** The wrong one is where the answers get interesting.
2. **The limit and one past it**, wherever a field states a limit.
3. **Every kind of user at every page.** Log in as each, try the page and its address.
4. **State after an error.** Send it wrong, fix it, send again.

Grey box testing is the name for mixing the two: test from outside, but peek at the code or the database to choose inputs or to check a result. That is what we did with the trimmed name. It is a fine way to work. Just be honest about which half found the bug.

## When each one is the right tool

Use white box tests for logic you can state as a rule: a price calculation, a date range, a parser. They are cheap and exact.

Use black box tests for anything a person does in sequence: signing up, creating a thing, paying, opening what they may not open. No amount of unit tests tells you that a visitor can get from the landing page to their first saved item.

If you [ship with a coding agent](https://everyrole.dev/blog/test-vibe-coded-app), lean harder on the outside. The agent wrote the code and the unit tests from the same understanding. A mistake in that understanding passes both. A test that only knows what the page should answer doesn’t share it.

## How EveryRole does it

EveryRole is black box only. It tests a web app from the outside, on the live site. It never reads the source code and needs no SDK or script. It explores the app signed out and signed in as each kind of user you give it a test login for, and suggests journeys from what it saw.

![EveryRole's list of the pages it saw on the practice app, with a column for the editor, the viewer and the visitor. The editor saw every page; the viewer has not been shown the new item form or an item's page.](https://everyrole.dev/s/blog/black-box-vs-white-box-testing/pages-seen.webp)

The pages EveryRole saw on our practice app, per kind of user, learned from the live site alone. A visitor is sent to the login page, so those stay Not yet.

That choice has a cost, and we would rather say it. EveryRole would not have found the trimmed name by reasoning about it. It types into the page like a person and records what the page answers. Of the four things we found from outside, it meets two the way a person would: the viewer refused at the form’s address, and another editor’s item answering not found. The other two needed a request sent past the browser, which it doesn’t do. Those stay on your list. Rules buried in the code are still a job for your unit tests. What it gives you is the other half: each journey, for each kind of user, checked against an answer you approved, after every deploy.

## Try it on your own app

EveryRole tests your app’s real user journeys for each kind of user, from the live site, and runs them after every deploy. Paste your app’s address to see what it finds.

[Start with your app](https://everyrole.dev/signup) [How it works](https://everyrole.dev/docs#start)

## Keep reading

User journeys

### [No-code E2E testing: what you gain, what you give up](https://everyrole.dev/blog/no-code-e2e-testing)

No-code E2E testing swaps the selector for something else. What that something is decides whether your tests survive a redesign, and what you lose in return.

Nov 22, 2026  6 min read

User journeys

### [Exploratory testing: a one-hour route through your app](https://everyrole.dev/blog/exploratory-testing)

Exploratory testing is using your own app with no script, on purpose, and writing down what it answers. A one-hour route to follow, starting signed out.

Nov 22, 2026  5 min read

User journeys

### [User journey testing: test the stops, not the clicks](https://everyrole.dev/blog/user-journey-testing)

User journey testing checks that one kind of user gets one thing done, start to finish. Write it as stops with answers, not as a list of clicks.

Nov 22, 2026  5 min read
