• info@helpingtesters.com
  • helpingtesters

White Box Testing

August 29, 2017 Types of Testing
white box testing, white box testing techniques, white box testing example

White box testing is the process of evaluating the internal structure of the product.The testing process involves looking at the structure of the code and evaluating the internal operations of all the modules present. White Box testing is always applicable to the lower levels of testing such as unit testing, integration testing etc..

White Box Testing involves the testing of a software for the following steps:

  • The flow of inputs and expected outputs.
  • The functionality of loops, statements, the flow of objects etc..
  • Broken links or poorly structured paths in each and every procedure.
  • Internal security structure and loopholes.

Hence, the white box testing evaluates the working flow of the software application. The process of white box testing starts with understanding the source code of the application. The source code study will include identifying the statements, the functionality flow, and the required security practices to improve the coding structure. A detailed analysis of the source code is necessary for an appropriate design and execution of the test cases

Types of White Box Testing

White Box Testing can be classified into 2 different categories such as:

⇒ Unit Testing: Concentrates on the smallest piece of code that can run independently. Here the test cases are developed to execute and evaluate the coding structure and functionality from the very basic level.

⇒ Integration Testing: Integration Testing is the process of combining the individual units to form modules and ensure the performance of each module.This testing occurs after unit testing.

White Box Testing Technique

The most widely used white box testing technique is Code Coverage Analysis. In simple words, the technique attempts to test all parts of the source code. On the basis of the testing requirements such as conditional loops, statements, functions etc.. the techniques can be specified into different categories.

  • Statement Coverage
  • Branch Coverage
  • Path Coverage
  • Condition Coverage
  • Multiple Condition Coverage

The above points explain how the testing process related to the coding style. The software performance issues arise mostly because of the bad coding style. To ensure the perfect coding standards and avoid security concerns the White Box Testing methods are so much helpful. White box testing becomes essential for software products of high-end applications.

Example for a White Box Testing

Consider the following Code: To check whether a number entered is EVEN or ODD

$number = $_POST['number'];
if (!(is_numeric($number) && is_int(0+$number))){
echo "<p style='color:red;'>Error: You entered a string. Please enter an Integer</p>";
if(($number % 2) == 0){
echo "You entered an Even number";
echo "You entered an Odd number";
} ?>

Statement Coverage

Statement Coverage tests whether the entire statements are covered or not during the execution time. Here the statements are:

  1. Accepting the number through textbox
  2. If condition, if (!(is_numeric($number) && is_int(0+$number))) checks whether the number is numeric or not.
  3. die() is executed if the number is not an integer.
  4. if(($number % 2)== 0) is true message displayed “You entered an Even number”
  5. Else Displayed “You entered an Odd number”

Test Case_01                 

number= 20

Result= 20%2==0;

OutPut= You entered an Even Number.

So the Statements Executed are 1,2 and 4.

Test Case_02    

number= 23

Result= 23%2!= 0;

OutPutYou Entered an Odd Number.

So the statements executed are 1,2 and 5.

Test Case_03 

number= 23.4

Result= Checks whether the number is numeric or not

OutPut= Error: You entered a string. Please enter an Integer

Here all the statements are covered and a White Box Tester can Identify whether any unwanted codes are working among the statements.

Branch Coverage

The Branch coverage will execute the entire branch of the condition statements properly. In the above example, all the IF and ELSE parts are executed properly.

For example, if die() is not given in 3rd statement the below codes will also execute at the time when the input is not an integer. This will cause an additional execution time.


Path Coverage

Path Coverage identifies the paths on which the code is executed. In the given example we have 2 decision statements 2 and 4.These will explain the path coverage of the codes. The flow chart given below will explain the path coverage of the code.

Condition Coverage

The condition coverage testing has been designed to evaluate whether each condition has been executed to TRUE or FALSE values. These testing will check the execution of the set of codes under both values[TRUE and FALSE].

Eg: In the above example, the condition IF number%2==0 will return TRUE or FALSE. For a complete condition coverage criteria, both Boolean values should be executed at least once.


Multiple Condition Coverage

Here, the condition IF is numeric is TRUE then goes to another condition IF number%2==0

Testcase_01: isNumeric = TRUE  AND number%2 = TRUE

Testcase_02: isNumeric = TRUE AND  number%2 = FALSE

Testcase_03: isNumeric = FALSE

Thus multiple condition coverage goes to execution of 2 or more sets of codes and sometimes repeated execution of statements.

The Branch and Path Coverage does not go through any bugs or issues related to the application.They simply identify the lines of codes which are left untouched.Sometimes some lines of codes may be executed without any important usage. All these kind of codes will increase the memory usage. This will lead to loading issues, security concerns etc…Ineffectively the White Box Testing will improve the quality of the software and hence the performance.Also, the testing process is highly related to the coding style used and this will obviously improve the upcoming versions of the software.


Benefits of White Box Testing

  • White Box Testing will improve the Quality of the Software and hence the performance.
  • When comes to adding more features the test results will ensure all the existing coding methods are intact and sufficient to modifications.
  • Ensures exact usage of resources.Resource utilization reduction is essential for effective memory management.
  • White Box Testing will detect the exact situations where stack overflows occur.
  • Also, the condition on which the application abort will detect.
  • Will identify the Object Issues such as object leaks, spiral problems etc..
  • Detects Unused objects.
  • Ensures all the objects are nullified and closed after use.
  • Examines the function usage.
  • The White Box testing strategy and test cases are useful for future enhancements of the software products.

About the author

Meera Sandeep author

1 Comment

software testing

December 18, 2018 at 10:54 am

Increadible post ..!!! The information that you provided on white box testing was very useful to me.keep writing..!!

Leave a Reply

Your email address will not be published.