White Box Testing In Software Testing With Example

.

White Box Testing With Example 

White box testing, also known as structural testing, is a software testing technique where the tester has access to the internal structure and workings of the software being tested. The purpose of white box testing is to verify that the code is working correctly and that all paths through the code have been tested.

Goal Of White Box Testing 

The main goal of white box testing is to ensure that the software code is working according to its design and that it meets the specified requirements. This type of testing involves understanding the code and using techniques such as code review, static analysis, and unit testing to identify errors and defects in the software.

White box testing is typically performed by software developers, who have access to the source code and are able to understand the logic and design of the software. This type of testing is used to ensure the reliability, maintainability, and efficiency of the software.

Some common techniques used in white box testing include statement coverage, branch coverage, path coverage, and condition coverage. These techniques help to identify specific areas of the code that need to be tested and ensure that all possible paths through the code are tested.

Examples of white box testing include unit testing, integration testing, and system testing. Here are some types of white box testing:

White Box Testing Types 

Statement Coverage Testing: This type of testing checks whether each statement in the code has been executed at least once.


Branch Coverage Testing: This type of testing checks whether each branch of the code has been executed at least once.


Condition Coverage Testing: This type of testing checks whether each condition in the code has been evaluated to both true and false at least once.


Decision Coverage Testing: This type of testing checks whether each decision point in the code has been evaluated to both true and false at least once.

Example of White Box Testing 

Here is an example of white box testing using condition coverage testing:

Suppose there is a function that takes two integers as input and returns their sum. The function contains an if statement that checks whether the first integer is greater than the second integer. If it is, the function returns the sum of the two integers. If it is not, the function returns the second integer minus the first integer.

To perform condition coverage testing, the tester would need to write test cases that evaluate the if statement to both true and false. For example, one test case might use the input values 3 and 5, while another test case might use the input values 5 and 3. This ensures that both branches of the if statement have been executed at least once.


Whitebox Testing in Software Testing


Post a Comment

0 Comments