The Wayback Machine - https://web.archive.org/web/20240828110733/https://www.geeksforgeeks.org/software-engineering-white-box-testing/
Open In App

White box Testing – Software Engineering

Last Updated : 25 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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 clear box testing or structural testing. White Box Testing is also known as transparent testing or open box testing.

Prerequisite – Software Testing | Basics

What is White 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

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.

Before we move in depth of the white box testing do you known that their are many different type of testing used in industry and some automation testing tools are there which automate the most of testing so if you wish to learn the latest industry level tools then you check-out our manual to automation testing course in which you will learn all these concept and tools

What Does White Box Testing Focus On?

White box testing uses detailed knowledge of a software’s inner workings to create very specific test cases.

  • Path Checking: Examines the different routes the program can take when it runs. Ensures that all decisions made by the program are correct, necessary, and efficient.
  • Output Validation: Tests different inputs to see if the function gives the right output each time.
  • Security Testing: Uses techniques like static code analysis to find and fix potential security issues in the software. Ensures the software is developed using secure practices.
  • Loop Testing: Checks the loops in the program to make sure they work correctly and efficiently. Ensures that loops handle variables properly within their scope.
  • Data Flow Testing: Follows the path of variables through the program to ensure they are declared, initialized, used, and manipulated correctly.

Types Of White Box Testing

White box testing can be done for different purposes. The three main types are:

  1. Unit Testing
  2. Integration Testing
  3. Regression Testing
Types-Of-White-Box-Testing

Types Of White Box Testing

Unit Testing

  • Checks if each part or function of the application works correctly.
  • Ensures the application meets design requirements during development.

Integration Testing

  • Examines how different parts of the application work together.
  • Done after unit testing to make sure components work well both alone and together.

Regression Testing

  • Verifies that changes or updates don’t break existing functionality.
  • Ensures the application still passes all existing tests after updates.

White Box Testing Techniques

One of the main benefits of white box testing is that it allows for testing every part of an application. To achieve complete code coverage, white box testing uses the following techniques:

1. 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, it 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

2. 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

3. Condition Coverage

In this technique, all individual conditions must be covered as shown in the following example:

  • READ X, Y
  • IF(X == 0 || Y == 0)
  • PRINT ‘0’
  • #TC1 – X = 0, Y = 55
  • #TC2 – X = 5, Y = 0

4. 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:

  • READ X, Y
  • IF(X == 0 || Y == 0)
  • PRINT ‘0’
  • #TC1: X = 0, Y = 0
  • #TC2: X = 0, Y = 5
  • #TC3: X = 55, Y = 0
  • #TC4: X = 55, Y = 5

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:

  • Make the corresponding control flow graph
  • Calculate the cyclomatic complexity
  • Find the independent paths
  • Design test cases corresponding to each independent path
  • V(G) = P + 1, where P is the number of predicate nodes in the flow graph
  • V(G) = E – N + 2, where E is the number of edges and N is the total number of nodes
  • V(G) = Number of non-overlapping regions in the graph
  • #P1: 1 – 2 – 4 – 7 – 8
  • #P2: 1 – 2 – 3 – 5 – 7 – 8
  • #P3: 1 – 2 – 3 – 6 – 7 – 8
  • #P4: 1 – 2 – 4 – 7 – 1 – . . . – 7 – 8

6. 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.

  • Simple loops: For simple loops of size n, test cases are designed that:
  1. Skip the loop entirely
  2. Only one pass through the loop
  3. 2 passes
  4. m passes, where m < n
  5. n-1 ans n+1 passes
  • 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.
  • Concatenated loops: Independent loops, one after another. Simple loop tests are applied for each. If they’re not independent, treat them like nesting.

Black Box vs White Box vs Gray Box Testing

Here is a simple comparison of Black Box, White Box, and Gray Box testing, highlighting key aspects:

Aspect

Black Box Testing

White Box Testing

Gray Box Testing

Knowledge of Internal Code

Not required

Required

Partially required

Other Names

Functional testing, data-driven testing, closed box testing

Structural testing, clear box testing, code-based testing, transparent testing

Translucent testing

Approach

Trial and error, based on external functionality

Verification of internal coding, system boundaries, and data domains

Combination of both black box and white box approaches

Test Case Input Size

Largest

Smaller compared to Black Box

Smaller than both Black Box and White Box

Finding Hidden Errors

Difficult

Easier due to internal code access

Challenging, may be found at user level

Algorithm Testing

Not suitable

Well-suited and recommended

Not suitable

Time Consumption

Depends on functional specifications

High due to complex code analysis

Moderate, faster than White Box

Process of White Box Testing

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

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
  • JSUnit.net
  • 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.
  9. Verification of Design: It verifies that the software’s internal design is implemented in accordance with the designated design documents.
  10. Check for Accurate Code: It verifies that the code operates in accordance with the guidelines and specifications.
  11. Identifying Coding Mistakes: It finds and fix programming flaws in your code, including syntactic and logical errors.
  12. Path Examination: It ensures that each possible path of code execution is explored and test various iterations of the code.
  13. Determining the Dead Code: It finds and remove any code that isn’t used when the programme is running normally (dead code).

Advantages of White Box Testing

  1. Thorough Testing : White box testing is thorough as the entire code and structures are tested.
  2. Code Optimization: It results in the optimization of code removing errors and helps in removing extra lines of code.
  3. Early Detection of Defects: It can start at an earlier stage as it doesn’t require any interface as in the case of black box testing.
  4. Integration with SDLC: White box testing can be easily started in Software Development Life Cycle.
  5. Detection of Complex Defects: Testers can identify defects that cannot be detected through other testing techniques.
  6. Comprehensive Test Cases: Testers can create more comprehensive and effective test cases that cover all code paths.
  7. Testers can ensure that the code meets coding standards and is optimized for performance.

Disadvantages of White Box Testing

  1. Programming Knowledge and Source Code Access: Testers need to have programming knowledge and access to the source code to perform tests.
  2. Overemphasis on Internal Workings: Testers may focus too much on the internal workings of the software and may miss external issues.
  3. Bias in Testing: Testers may have a biased view of the software since they are familiar with its internal workings.
  4. Test Case Overhead: Redesigning code and rewriting code needs test cases to be written again.
  5. Dependency on Tester Expertise: Testers are required to have in-depth knowledge of the code and programming language as opposed to black-box testing.
  6. Inability to Detect Missing Functionalities: Missing functionalities cannot be detected as the code that exists is tested.
  7. Increased Production Errors: High chances of errors in production.

Conclusion

White box testing examines a software’s internal code and logic to ensure thorough testing and code optimization . It includes unit , integration , and regression testing , using techniques like statement and branch coverage. While it offers early defect detection and improved performance, it requires programming knowledge and may overlook external issues.

Frequently Asked Questions on White box Testing

Which testing is more expensive?

Integration tests.

What is an example of black box testing?

Dynamic code analysis.

What is API in manual testing?

Application Program Interface (API)



Previous Article
Next Article

Similar Reads

Differences between White Box Testing and Gray Box Testing
White Box Testing: White Box Testing is a type of Software Testing in which the internal structure, design and implementation of the software application that is being tested is fully known to the tester. Gray Box Testing: Gray Box Testing is a software testing technique which is a combination of Black Box Testing technique and White Box Testing te
2 min read
Differences between Black Box Testing and White Box Testing
Understanding the differences between Black Box Testing and White Box Testing is important for checking the quality and reliability of software products. Both methodologies play vital roles in the software development lifecycle but approach testing from different perspectives. This guide will explore the fundamentals of Black Box Testing and White
6 min read
Software Testing - White Box Penetration Testing
Penetration testing refers to the authorized security attacks that are performed on your system to identify the security vulnerabilities and then resolve these security issues. An essential component of software testing is white box penetration testing, which evaluates the security of an algorithm, code, and internal system architecture. White box
10 min read
Difference between Black Box and White and Grey Box Testing
software's1. Black Box Testing :Black box testing is a type of software testing in which the functionality of the software is not known. The testing is done without the internal knowledge of the products. It is also called Functional testing. Black-box testing focuses on software’s external attributes and behavior. This type of testing looks at an
3 min read
Difference between Black Box Testing and Gray Box Testing
Black Box Testing: Black Box Testing is a Software Testing technique in which the tester doesn't know the internal structure, design and implementation of the software application that is being tested. Gray Box Testing: Gray Box Testing is a software testing technique which is a combination of Black Box Testing technique and White Box Testing techn
4 min read
Black Box Testing - Software Engineering
Black Box Testing is an important part of making sure software works as it should. Instead of peeking into the code, testers check how the software behaves from the outside, just like users would. This helps catch any issues or bugs that might affect how the software works. This simple guide gives you an overview of what Black Box Testing is all ab
11 min read
Gray Box Testing - Software Testing
The Gray Box Testing is a combination of Black Box and White Box Testing. This article focuses on discussing the Gray Box Testing in detail. Table of Content What is Gray Box Testing?Objectives of Gray Box TestingGray Box Testing TechniquesGray Box Testing Techniques imageAdvantages of Gray Box TestingDisadvantages of Gray Box TestingConclusionFreq
6 min read
Sanity Testing Vs Smoke Testing - Software Engineering
Smoke Testing is a type of testing that is done to ensure that the acute functionalities of the program are working fine. It is also known as a subset of acceptance testing, and it is used to test all over the function of the system/product. On the other hand. Sanity Testing is done to check the bugs have been fixed after the build. And it is also
5 min read
Comparison between Regression Testing and Re-Testing - Software Engineering
This article focuses on discussing the comparison between Regression Testing and Re-Testing. What is Regression Testing?Regression Testing is a type of software testing, which is used to verify that modifications in the software or the environment have not caused any unintended adverse side effects. This technique involves retesting the entire syst
4 min read
Introduction to Software Engineering - Software Engineering
Software is a program or set of programs containing instructions that provide the desired functionality. Engineering is the process of designing and building something that serves a particular purpose and finds a cost-effective solution to problems. Table of Content What is Software Engineering?Key Principles of Software EngineeringMain Attributes
9 min read
Unit Testing, Integration Testing, Priority Testing using TestNG in Java
TestNG is an automated testing framework. In this tutorial, let us explore more about how it can be used in a software lifecycle. Unit Testing Instead of testing the whole program, testing the code at the class level, method level, etc., is called Unit Testing The code has to be split into separate classes and methods so that testing can be carried
6 min read
Split Testing or Bucket Testing or A/B Testing
Bucket testing, also known as A/B testing or Split testing, is a method of comparing two versions of a web page to see which one performs better. The goal of split testing is to improve the conversion rate of a website by testing different versions of the page and seeing which one produces the most desired outcome. There are a few different ways to
15+ min read
Selenium Testing vs QTP Testing vs Cucumber Testing
Automation testing will ensure you great results because it's beneficial to increased test coverage. Manual testing used to cover only few test cases at one time as compared to manual testing cover more than that. During automated test cases it's not all test cases will perform under the tester. Automation testing is the best option out of there. S
6 min read
Principles of software testing - Software Testing
Software testing is an important aspect of software development, ensuring that applications function correctly and meet user expectations. In this article, we will go into the principles of software testing, exploring key concepts and methodologies to enhance product quality. From test planning to execution and analysis, understanding these princip
10 min read
Reverse Engineering - Software Engineering
Software Reverse Engineering is a process of recovering the design, requirement specifications, and functions of a product from an analysis of its code. It builds a program database and generates information from this. This article focuses on discussing reverse engineering in detail. What is Reverse Engineering?Reverse engineering can extract desig
6 min read
Difference between Software Engineering process and Conventional Engineering Process
Software Engineering Process and Conventional Engineering Process, both are processes related to computers and development. In this article, we will see the similarities as well as differences between both, that is Software Engineering Process and the Conventional Engineering Process. Table of Content Software Engineering ProcessConventional Engine
4 min read
Re-engineering - Software Engineering
Software Re-engineering is a process of software development that is done to improve the maintainability of a software system. Re-engineering is the examination and alteration of a system to reconstitute it in a new form. This process encompasses a combination of sub-processes like reverse engineering, forward engineering, reconstructing, etc.  Tab
8 min read
Difference between Software Engineering and Computer Engineering
Software engineering and Computer engineering are two distinct disciplines that focus on different aspects of computer systems. While both fields require a strong foundation in computer science and mathematics, software engineering is focused on software development processes, while computer engineering is focused on the physical components and sys
6 min read
Evolution of Software Engineering: From an Art To Engineering Discipline
Software Engineering is a systematic and cost-effective technique for software development. It is an engineering approach to developing software. For example: If someone wants to travel from Punjab to Delhi. There are two approaches one can follow to achieve the same result: The normal approach is to go out and catch the bus/train that is available
13 min read
Requirements Engineering Process in Software Engineering
Requirements Engineering is the process of identifying, eliciting, analyzing, specifying, validating, and managing the needs and expectations of stakeholders for a software system. Table of Content What is Requirements Engineering?Requirements Engineering ProcessTools Involved in Requirement EngineeringAdvantages of Requirements Engineering Process
13 min read
Software Engineering | Program Testing
Testing a program consists of providing the program with a group or take a look at inputs (or test cases) and perceptive if the program behaves needless to say. If the program fails to behave needless to say, then the conditions below that failure happen are noted for later debugging and correction. Some normally used terms related to program testi
2 min read
Comparison Testing in Software Engineering
When any software development takes place, a series of steps or development processes are followed to finally build a quality software product. All the activities comes under SDLC (Software Development Life Cycle) which works as a software development framework and which is followed by the software developer/engineer team for the building of a high
4 min read
Negative Testing in Software Engineering
Every software development process follows Software Development Life Cycle(SDLC) finally to develop a quality software product. Software testing is one of the important phases as it only ensures the quality of the product. So, for that different types of software testing are performed to check different parameters or test cases. Negative testing is
7 min read
Thread Testing in Software Engineering
Prerequisite: Software Testing Before knowing thread testing let's know about thread. Generally a thread is the smallest unit of work that any system can perform. Due to thread multiple tasks executes simultaneously at a time. So while developing software application we make use of threading concept a lot. While testing, these needs to be tested pr
3 min read
Statistical Testing - Software Engineering
Statistical Testing is a testing method whose objective is to work out the undependable software package products instead of discovering errors. check cases are designed for applied mathematics testing with a wholly different objective than those of typical testing. Operation Profile: Different classes of users might use a software package for vari
2 min read
Fault Injection testing - Software Engineering
Fault injection is a technique used in software engineering to test the resilience of a software system. The idea is to intentionally introduce errors or faults into the system to see how it reacts and to identify potential weaknesses. This can be achieved in several ways, such as: Hardware faults: This involves physically altering hardware compone
6 min read
Software Engineering - Agent-Oriented Testing
Testing determines the correctness of the software under a predefined script. It identifies any gaps, errors, or missing requirements contrary to actual requirements. The purpose of testing is to detect failures of the application so that failures can be discovered and corrected. Testing is the process of finding bugs in developed or existing appli
5 min read
Development Testing in Software Engineering
Prerequisite - Types of Software Testing Development Testing - It is a method of applying testing practices consistently throughout the software development life cycle process. This testing ensures the detection of bugs or errors at the right time which further ensures delay of any kind of risk in terms of time and cost. Development Testing aims to
5 min read
Cleanroom Testing - Software Engineering
Cleanroom Testing was pioneered by IBM. This kind of testing depends heavily on walkthroughs, inspection, and formal verification. The programmers don’t seem to be allowed to check any of their code by corporal punishment the code apart from doing a little syntax testing employing a compiler. The computer code development philosophy relies on avoid
3 min read
Path Testing in Software Engineering
Path Testing is a method that is used to design the test cases. In the path testing method, the control flow graph of a program is designed to find a set of linearly independent paths of execution. In this method, Cyclomatic Complexity is used to determine the number of linearly independent paths and then test cases are generated for each path.  It
2 min read