Skip to main content
Back to Blog

What Does the Box Say? White, Black and Gray Box Testing Techniques

Best PracticesMarch 15, 20207 min readQA Camp Team
What Doesthe BoxSay?TESTING TECHNIQUESWHITE - BLACK - GRAY BOXWHITE BOXcode visible?INOUTBLACK BOXbehavior onlyVSGRAY BOXpartial access

Do you know that testing is science? Every new day, the global testers' community contributes to the knowledge base, sharing experience, and their own achievements. This is how knowledge about high-level test classification was born.

So, the highest level in the hierarchy of approaches to testing is the concept of type, which includes several testing techniques at once. That is, several different techniques may correspond to one type of testing. Let's take a look at several types of testing that differ in whether we - as testers - understand the internal structure of the test object.

White Box#

Also known as: open box, clear box, glass box testing

Why the "white box"? The tested app, in this case, is a transparent box whose contents we can see perfectly. This means we know the app inside out.

According to the ISTQB, white box testing is:

  • Testing based on the analysis of the internal structure of a component or system.
  • A test design procedure for writing or selecting test cases based on the analysis of the internal structure of the system or component.

The white box method is applicable when we have access to the internal structure and application code, and also have enough knowledge to understand what we see. We select input data based on knowing the code that will process this data. We also know what the result of this processing should be. Knowledge of all the features of the application being tested is mandatory for this technique. White box testing is the process of looking into the internal structure of the system, beyond its external interfaces.

When a tester uses the white box method, it can be compared with the work of an auto mechanic who studies the engine of a car to understand why it does not start. The white box technique is applicable at different levels of testing, from unit to system, but it is mainly used for unit testing of the component.

Example: The tester (who is usually also a developer) examines the code for the input field on a web page. Then the tester determines all possible - both correct and incorrect - user inputs and compares the actual result with the expected one. In this case, the expected result is determined by how the application code should work.

White Box Advantages#

  • Testing can be done in the early stages of development, as there is no need for a user interface.
  • More thorough testing is possible, covering a large number of application execution paths.

White Box Disadvantages#

  • The tester needs to have a lot of special knowledge.
  • When using test automation at this level, it can be quite difficult and expensive to maintain test scripts, especially if the app is constantly changing.

Black Box#

Also known as: closed box testing, specification-based testing, requirements-based testing

Why the "black box"? The tested app, in this case, is a lighttight box whose contents we cannot see. This means we know what we should get out of the app, but we don't know how it works.

According to the ISTQB, black box testing is:

  • Testing, both functional and non-functional, not involving knowledge of the internal structure of the component or system.
  • A test design procedure for writing or selecting test cases based on the analysis of the functional or non-functional specification of a component or system without knowledge of its internal structure.

Black box testing is a technique based on interacting exclusively with the external interfaces of the system. We use this method when we do not have access to the internal structure and application code, or we do not have enough knowledge to understand them. We influence the application in different ways and check the reaction, simulating real situations of the application interacting with users or other applications.

According to the black box method, the main source for creating test cases is the documentation - especially the requirements - and common sense. The black box technique is applicable at all levels of testing (from unit to acceptance), for which there is a specification.

The purpose of this technique is to search for bugs in the following categories:

  • Incorrectly implemented or missing functions
  • Interface bugs
  • Bugs in data structures
  • External database access bugs
  • Behavior bugs or insufficient system performance

Example: The tester checks the website without knowing how it is implemented. The tester uses only the input fields and buttons that the developer has provided. The expected result is recorded in the specification. The tester receives the data, compares it with the specification, and comes to a conclusion about the application's performance.

Black Box Advantages#

  • Testing is done from the perspective of the end user and can help detect inaccuracies and contradictions in the specification.
  • The tester does not need to know programming languages or the specifics of the application implementation.
  • Testing can be done by specialists who are not involved in the development process, which helps avoid biased attitudes.
  • A tester can start writing test cases as soon as the specification is ready.

Black Box Disadvantages#

  • Only a limited number of ways to execute an application can be tested.
  • Without a clear specification, it is rather difficult to make effective test cases.
  • Some tests may be redundant if they have already been conducted by the developer at the unit testing level.

White Box vs Black Box: A Comparison#

| | White Box | Black Box | |---|---|---| | Advantages | Shows hidden problems and simplifies diagnosis | No (deep) programming knowledge required | | | Allows automation of test cases at early stages | Behavior investigated in the context of the real environment | | | Has a developed system of metrics | Explores behavior in real user scenarios | | | Stimulates developers to write quality code | Test cases can be created at the first requirements stage | | Disadvantages | Cannot be performed without sufficient programming knowledge | Risk of repeating test cases already completed by developers | | | Focused on implemented functionality - may miss unfulfilled requirements | Some application behaviors may remain untested | | | Investigated in isolation from real environment | High-quality documentation required for effective test cases |

Gray Box#

Why the "gray box"? It's the color that appears when you mix black and white. This means we know what we should get out of the app, but we are not sure exactly how it works.

The gray box method is a combination of the white box and black box methods where the tester has access to one part of the code and the architecture only. That is, the internal device of the application is only partially known. The tester may be given access to the internal structure and software operation algorithms for writing the most effective test cases, but the testing itself is carried out using the black box technique - from the user's point of view.

Usually, teams talk about white or black box methods as applied to certain parts of the application while recognizing that the entire application is being tested using the gray box method.

The gray box technique is applicable at different levels of testing, from unit to system, but is mainly used at the integration level to test the interaction of different application units.

Example: The tester studies the application code to better understand the principles of its operation and possible ways of implementation. This knowledge helps write a test case that will check the selected functionality thoroughly. However, the tester only checks individual parts of the application from the user's point of view, as they do not have access to the full codebase.

Gray Box Advantages and Disadvantages#

The gray box method combines the advantages and disadvantages of the white and black box methods. It offers more insight than pure black box testing while remaining accessible to testers who do not have full code access.

Related Articles

Web ApplicationsTestingFeaturesPART 1UI · FORMS · NAVIGATION · EDGE CASEShttps://app.example.comForm ValidationNavigation FlowError HandlingSTARTOK?PASSFAIL
Best Practices

Web Applications Testing Features — Part 1

Explore the key features and considerations when testing web applications.

February 12, 20266 min read
Read More
SecurityTestingPhases, Types, and Best Practices<PLANNING TO GO-LIVE>4 PHASES - END-TO-END SECURITY TESTINGSECURITY TEST FLOWSECURITY TEST FLOW01PLANNING02LEARNING03ATTACKING04GO-LIVE
Best Practices

Security Testing: Phases, Types, and Best Practices

A structured guide to planning, executing, and reporting security assessments — from scoping to remediation.

February 3, 20268 min read
Read More
UsabilityTestingCustomers Come First<USER EXPERIENCE MATTERS>REAL USERS - REAL FEEDBACK - REAL RESULTSHEROSIGN UPbad"Couldn't find thebutton anywhere…"good"Super intuitive, foundeverything instantly!"FEEDBACKUSER
Best Practices

Usability Testing: Customers Come First

How usability testing helps create products that resonate.

January 20, 20266 min read
Read More

Need Expert QA for Your Project?

Let our team help you deliver software your users will love.

Get a Free Consultation