Black box testing checks what software does from the outside, without looking at the code. White box testing uses knowledge of the code to test internal logic, branches and paths. Black box suits acceptance tests and user flows, and white box suits unit tests and coverage work. Most teams use both, and grey box testing sits between them.
What is black box testing
In black box testing the tester knows the inputs and the expected outputs and treats the system as a closed box. Examples are checking that a signup form accepts valid data and rejects invalid data, or that a payment flow ends with the right confirmation. The tester does not need to read the code, which makes it a good fit for acceptance testing and for people who represent the user.
What is white box testing
In white box testing the tester knows the code and designs tests around its structure. They check that each branch runs, that edge cases in a function behave correctly and that error handling works. Unit tests are the most common form. Coverage tools show which lines the tests reach.
How do they compare
| Black box | White box | |
|---|---|---|
| Knowledge of code | Not needed | Needed |
| Tests | Behaviour and user flows | Logic, branches and paths |
| Typical level | System and acceptance | Unit and integration |
| Finds | Missing or wrong features | Logic errors and untested paths |
| Done by | QA, product, users | Developers, test engineers |
What is grey box testing
Grey box testing uses partial knowledge of the internals, such as the database schema or the API contract, to design better black box tests. A tester who knows how data is stored can check that a form submission wrote the right records, for example.
Which one should you use
Both, at different levels. White box tests run fast and catch logic errors close to where they are made. Black box tests check that the whole product works together. A set of tests at only one level leaves gaps, and the combination is what keeps regression testing affordable. Broader practice sits under software quality assurance.
Does this change with AI-generated code
Generated code makes both styles matter more. White box tests catch logic that looks right and is not, and black box checks confirm the behaviour users need. Tests should be written against the intended behaviour, not copied from the generated code, as covered in testing software you didn't design.
How do you balance the two in practice
Many teams use a pyramid. Most tests are fast white box unit tests, fewer are integration tests, and a small set of black box end-to-end tests covers the key user journeys. Keep the end-to-end set small, because those tests are slow and can be fragile.
Review the balance when bugs escape. If defects reach users, add black box checks on the flow that failed. If they appear deep in the logic, add unit tests around that code.
Who should write each type
Developers write white box tests as they write the code, since they know the logic best. QA engineers or product owners design black box tests from the requirements, so that the checks reflect what users need and not what the code happens to do. Reviewing each other's tests catches gaps that either side would miss alone.
What does this mean when you hire
A strong QA or test engineer can design tests at both levels and automate the ones that repeat. Miyagami places senior engineers through the QA engineers page, full-time from €5,600 a month on a three-month minimum, with replacement at our cost if the fit is wrong.
Every engineer is tested by an AI-native tech lead who works with AI every day, explained on how we vet.
Short answers
What is the main difference?
Black box testing looks at behaviour without seeing the code, and white box testing uses the code to test internal logic.
What is grey box testing?
It combines both, with partial knowledge of the internals, for example the database schema or API contracts.
Which one should you use?
Both. White box finds logic errors early, and black box checks that the product works for users.
Are unit tests white box?
Yes. Unit tests are written with knowledge of the code they check.
