loader image
White Box Testing

White Box Testing

30 July 2022 10 MIN READ BY Rajesh K

What is White Box Testing

A software testing technique that evaluates the working of an application software by testing the functioning of its source code and its internal structure.

  • The source code is accessible or visible to the software testers and needs to be tested. So, programming knowledge or skills are inevitable for software testers.
  • Every line of the source code is tested here which ultimately results in inspection of the inner working of the entire software system.
  • Software developers also do white box testing as this involves testing of the functioning, structure and working flow of the source code. Software developers do this mostly after
    • fixing a bug, or
    • after the completion of a new functionality or feature or a module, and
    • before the changes are submitted for the software testers to test further.

Advantages of White Box Testing

The advantages of white box testing can be briefly summarized as,

  • Very meticulous as it tests the entire source code and structure —> The transparency of the internal code structure is beneficial as it helps to identify the type of input data needed for testing.
  • Code optimization occurs as a result of white box testing and the lines of code which are error- prone and not required or not significant gets removed.
  • This type of testing can be started at an earlier stage without waiting for the completion of development.
  • The test cases for white box testing are easy to automate.
  • Communication burden between software developers and software testers gets reduced as software testers performing white box testing are expected to possess knowledge in programming languages and skills.

White Box Testing Process

White box testing begins by scrutinizing and understanding the source code, its design and structure, corresponding to the application software to be tested, so that proper test cases can be created.

1. Familiarizing the Source code:-

  • The software tester should familiarize with the internal source code, its structure and its process flow.
    “The tester should also be well versed with the programming language used to develop the application.”
  • The different functionalities embedded in the application should be understood through its source code. This will be helpful in identifying and creating different test cases for testing the application.
  • The tester should be aware of secure coding practices as security is a major concern while testing an application.

2. Make Test Cases and Execute them:-

  • Test cases for each process in the application software to be tested are created and executed by the software tester either manually or after automating it through scripts.
  • Test cases for every single path in the working flow of the source code are created and executed.
  • The results are analysed and recorded after executing the test cases.

Types of White Box Testing

White Box testing includes different testing types which are used to evaluate an application software.

i. Unit Testing:-

  • Tests a Unit, which is the smallest block of code that can be logically used for a purpose. Unit testing ensures the proper functioning of each component of the source code as intended.

ii. Mutation Testing:-

Based on modifications or mutations made to the source code to examine if the test cases executed can reveal bugs in the code.

  • If all the test cases fail, then the source code tested is working perfectly.
  • If any of the test cases passes the test, it signifies an error or bug in the source code

iii. Integration Testing:-

    Intended to check the combined working of different Units/Modules/Components of the application’s source code.

  • Ensures that the modules that worked correctly independently are also working fine when combined.
    “The purpose of this type of testing is to expose any errors in the interaction of different units when associated together.”

White Box Testing techniques

White box testing aims to scrutinize the source code of an application software comprehensively

1. Code Coverage Analysis:-

  • Identifies areas of a program that are not yet tested by the set of test cases created and executed. After identifying these gaps, further test cases are created to test and verify the untried parts of the code.
The most popular white box testing techniques related to Code Coverage are Statement Coverage, Branch Coverage, Path Coverage, Function Coverage, Condition Coverage and Multiple Condition Coverage.

2. Statement Coverage:-

  • Ensures that all executable statements of the source code of an application software are executed and tested at least once. Finds
  • branch instructions or other executable statements that are not executed or used by the system, and
  • dead codes.
  • Statement coverage = (Number of statements executed/Total number of statements)*100.

3. Branch Coverage:-

  • The software tester identifies all conditional and unconditional branches and ensures that each branch operation is executed and tested at least once. Every possible branch within an application is tested here.
Branch coverage = (Number of executed branches/Total number of branches)*100.

4. Path Coverage:-

  • All possible paths covering each executable statement and branch instruction are executed and tested at least once. The control flow of the source code should be understood well to achieve this.
  • Assures that all program paths are examined at least once.
  • Broken paths and redundant paths can be identified using this testing.
Path Coverage = (Number of paths traversed/Total number of paths in the program)*100.

5. Function Coverage:-

  • Evaluates the defined functions within the source code. Required input parameters are passed to these functions to examine if the working of each function is logical as intended.

6. Condition Coverage:-

  • Evaluates the variables or expressions in a conditional statement. The end result of each logical condition is evaluated and tested here.

7. Multiple condition coverage:-

  • Evaluates all the different combinations of the possible outcomes of conditions for a decision to be made.


The ease and speed with which white box testing can be executed depends on the size of the application software being tested. Small applications can be tested fast but large applications may consume more time.

  • Since the testing happens through the source code of the application, maximum structural loopholes and bugs can be identified at a profound level.
  • Software developers and QA personnels can bring greater efficiency, accuracy, and cost-effectiveness to white box testing through its automation.
  • Because white box tests can be automated, they can be executed in CI pipelines to provide faster feedback for the software developers while evaluating the source code.
  • White box testing is widely used in the software industry especially for applications dealing with high risk or critical business.