Open In App
Related Articles

Software Engineering | White box Testing

Improve Article
Save Article
Like Article

White box testing techniques analyze the internal structures the used data structures, internal design, code structure, and the working of the software rather than just the functionality as in black box testing. It is also called glass box testing or clear box testing or structural testing. White Box Testing is also known as transparent testing or open box testing. 

White box testing is a software testing technique that involves testing the internal structure and workings of a software application. The tester has access to the source code and uses this knowledge to design test cases that can verify the correctness of the software at the code level.

White box testing is also known as structural testing or code-based testing, and it is used to test the software’s internal logic, flow, and structure. The tester creates test cases to examine the code paths and logic flows to ensure they meet the specified requirements.

Prerequisite – Software Testing | Basics 

Working process of white box testing:

  • Input: Requirements, Functional specifications, design documents, source code.
  • Processing: Performing risk analysis to guide through the entire process.
  • Proper test planning: Designing test cases so as to cover the entire code. Execute rinse-repeat until error-free software is reached. Also, the results are communicated.
  • Output: Preparing final report of the entire testing process.

Testing techniques:

  • Statement coverage: In this technique, the aim is to traverse all statements at least once. Hence, each line of code is tested. In the case of a flowchart, every node must be traversed at least once. Since all lines of code are covered, helps in pointing out faulty code.
Minimum 2 test cases are required so that all the nodes can be traversed at least once

Statement Coverage Example

  • Branch Coverage: In this technique, test cases are designed so that each branch from all decision points is traversed at least once. In a flowchart, all edges must be traversed at least once.

4 test cases are required such that all branches of all decisions are covered, i.e, all edges of the flowchart are covered

  • Condition Coverage: In this technique, all individual conditions must be covered as shown in the following example:
    1. READ X, Y
    2. IF(X == 0 || Y == 0)
    3. PRINT ‘0’
    4. #TC1 – X = 0, Y = 55
    5. #TC2 – X = 5, Y = 0
  • Multiple Condition Coverage: In this technique, all the possible combinations of the possible outcomes of conditions are tested at least once. Let’s consider the following example:
    1. READ X, Y
    2. IF(X == 0 || Y == 0)
    3. PRINT ‘0’
    4. #TC1: X = 0, Y = 0
    5. #TC2: X = 0, Y = 5
    6. #TC3: X = 55, Y = 0
    7. #TC4: X = 55, Y = 5
  • Basis Path Testing: In this technique, control flow graphs are made from code or flowchart and then Cyclomatic complexity is calculated which defines the number of independent paths so that the minimal number of test cases can be designed for each independent path. Steps:
    1. Make the corresponding control flow graph
    2. Calculate the cyclomatic complexity
    3. Find the independent paths
    4. Design test cases corresponding to each independent path
    5. V(G) = P + 1, where P is the number of predicate nodes in the flow graph
    6. V(G) = E – N + 2, where E is the number of edges and N is the total number of nodes
    7. V(G) = Number of non-overlapping regions in the graph
    8. #P1: 1 – 2 – 4 – 7 – 8
    9. #P2: 1 – 2 – 3 – 5 – 7 – 8
    10. #P3: 1 – 2 – 3 – 6 – 7 – 8
    11. #P4: 1 – 2 – 4 – 7 – 1 – . . . – 7 – 8
  • Loop Testing: Loops are widely used and these are fundamental to many algorithms hence, their testing is very important. Errors often occur at the beginnings and ends of loops.
    1. Simple loops: For simple loops of size n, test cases are designed that:
      • Skip the loop entirely
      • Only one pass through the loop
      • 2 passes
      • m passes, where m < n
      • n-1 ans n+1 passes
    2. Nested loops: For nested loops, all the loops are set to their minimum count and we start from the innermost loop. Simple loop tests are conducted for the innermost loop and this is worked outwards till all the loops have been tested.
    3. Concatenated loops: Independent loops, one after another. Simple loop tests are applied for each. If they’re not independent, treat them like nesting.

White Testing is Performed in 2 Steps:

1. Tester should understand the code well

2. Tester should write some code for test cases and execute them

Tools required for White box Testing:

  • PyUnit
  • Sqlmap
  • Nmap
  • Parasoft Jtest
  • Nunit
  • VeraUnit
  • CppUnit
  • Bugzilla
  • Fiddler
  • OpenGrok
  • Wireshark
  • HP Fortify
  • CSUnit

Features of white box testing:

  1. Code coverage analysis: White box testing helps to analyze the code coverage of an application, which helps to identify the areas of the code that are not being tested.
  2. Access to the source code: White box testing requires access to the application’s source code, which makes it possible to test individual functions, methods, and modules.
  3. Knowledge of programming languages: Testers performing white box testing must have knowledge of programming languages like Java, C++, Python, and PHP to understand the code structure and write tests.
  4. Identifying logical errors: White box testing helps to identify logical errors in the code, such as infinite loops or incorrect conditional statements.
  5. Integration testing: White box testing is useful for integration testing, as it allows testers to verify that the different components of an application are working together as expected.
  6. Unit testing: White box testing is also used for unit testing, which involves testing individual units of code to ensure that they are working correctly.
  7. Optimization of code: White box testing can help to optimize the code by identifying any performance issues, redundant code, or other areas that can be improved.
  8. Security testing: White box testing can also be used for security testing, as it allows testers to identify any vulnerabilities in the application’s code.


  1. White box testing is thorough as the entire code and structures are tested.
  2. It results in the optimization of code removing errors and helps in removing extra lines of code.
  3. It can start at an earlier stage as it doesn’t require any interface as in the case of black box testing.
  4. Easy to automate.
  5. White box testing can be easily started in Software Development Life Cycle.
  6. Easy Code Optimization.

Some of the advantages of white box testing include:

  • Testers can identify defects that cannot be detected through other testing techniques.
  • Testers can create more comprehensive and effective test cases that cover all code paths.
  • Testers can ensure that the code meets coding standards and is optimized for performance.

However, there are also some disadvantages to white box testing, such as:

  • Testers need to have programming knowledge and access to the source code to perform tests.
  • Testers may focus too much on the internal workings of the software and may miss external issues.
  • Testers may have a biased view of the software since they are familiar with its internal workings.
    Overall, white box testing is an important technique in software engineering, and it is useful for identifying defects and ensuring that software applications meet their requirements and specifications at the code level


  1. It is very expensive.
  2. Redesigning code and rewriting code needs test cases to be written again.
  3. Testers are required to have in-depth knowledge of the code and programming language as opposed to black-box testing.
  4. Missing functionalities cannot be detected as the code that exists is tested.
  5. Very complex and at times not realistic.
  6. Much more chances of Errors in production.
Last Updated : 09 May, 2023
Like Article
Save Article
Similar Reads