Grey box testing
Grey box testing is a testing approach in which the tester has partial knowledge of the system's internals, such as its architecture, its database schema or its API contracts, but tests it through its external interfaces the way a user or a client system would. Black box testing uses no internal knowledge and white box testing uses all of it; grey box testing uses enough to aim the tests.
The longer version
The tester knows the shape of the system without reading its code: how the front end talks to the back end, which requests a page makes, what the tables are named, where the cache sits. Tests are still driven from the outside, through the UI or the API, but the knowledge decides which tests to write. Knowing that a search result is cached for a minute suggests testing what happens to a record edited within that minute. Knowing that two services share a database suggests testing what happens when one is deployed before the other.
Black box testing treats the system as opaque and derives every test from the specification, which is how a user or an acceptance tester works. White box testing derives tests from the code itself, covering branches and paths, which is how a developer unit tests. Grey box borrows from both: the tests look like black box tests and are chosen like white box tests. It is the natural mode of integration testing, security testing and most testing done by a QA engineer who has read the design document.
Partial knowledge gets treated as complete. A tester who knows the API contract assumes the front end honours it and skips the case where it does not. Or the knowledge goes stale: the schema the tester learned two releases ago no longer describes the system, and tests aimed at a table that has since been split cover nothing. Grey box knowledge has to be refreshed against the current design, and the tests it produces still have to be run from the outside, or the approach collapses into a badly informed white box test.
Common questions
What is the difference between black box, white box and grey box testing?
Black box testing uses no knowledge of the internals and derives tests from requirements. White box testing uses full knowledge of the code and derives tests from its structure. Grey box testing uses partial knowledge, such as the architecture or the data model, to choose tests that are still executed through the external interface.
Who does grey box testing?
Usually a QA engineer or a test engineer who has read the design documents and can inspect requests and data, but does not own the code. Developers testing another team's service also work this way, as do penetration testers who are given the architecture but not the source.
Is integration testing grey box testing?
Integration testing is most often done grey box. The tester knows how the components connect, which is internal knowledge, and uses it to target the seams, but drives the test through the interfaces those components expose rather than through their code. A pure black box integration test would not know where the seams were.
What are examples of grey box testing?
Submitting a form through the browser while watching the request it sends, because the tester knows the API contract. Testing a search page with records placed directly in the database to reach states the interface cannot create. Probing a web application with the architecture diagram in hand, as a penetration tester does. Editing a record and reloading within the interval the tester knows the cache holds it, to see which version the page shows.
What are the advantages and disadvantages of grey box testing?
The advantage is aim: knowing where the seams, caches and shared tables are lets a tester write fewer tests that reach more of the places defects hide, while still testing what a user or client system sees. The disadvantages are stale knowledge, when the design the tester learned no longer matches the code, and false confidence, when the tester assumes the parts they understand behave as documented and skips the case where they do not.
Bug reports that arrive ready to triage.
Collect replay, console, network and browser context with the Free plan.