What is white box testing?

This is a common interview question but many of the tester are unable to answer in proper way. Let us discuss in details. What are white box, black box and grey box testing and how to perform them? Today we will discuss only white box testing technique.

White Box Testing :
White box testing has lots of other names also like transparent box testing, glass box testing, and clear box testing etc. here tester need to know about coding and how coding works and how it generates the output. Quit disliked testing type for testers. Especially for those who hate coding. Most of you have might have heard that tester does not need to have coding knowledge, yes it’s true but partially, in this type of testing tester need to know about coding. See the following diagram.

white box testing


Here tester give the input and system produce the output. Tester need to check how system is going to produce the output.If there is a wrong output then tester need to debug the code/program and find out where is the bug present in the code. Tester execute the code line by line to find out the ambiguities present in the code.

How to perform white box testing? basically there are number of white box testing techniques, each of white box testing techniques start from understanding the code, tester first understand the code and imagine its behaviors and write the test cases as per the understanding. White box testing techniques are like control flow testing, data flow testing, decision coverage testing, path testing and many more.

Apart from just the testing output, in white box testing, tester also test and try to find out undefined variables, dead codes, useless objects, loop holes and functions, those mistakes of developers make code execution time longer hence application gets slow down. Developers are developers they just want to get correct output so they try two –three or many logic together while doing this they make code bulky and buggy.

There are many looping, if else i.e. conditional statement in the code so it is necessary that all condition, loops should get tested at least once which is possible using white box testing techniques.Lets see few white box testing techniques.

Unit Testing: The first level of testing, here testing is done by the developer, developer test his program, functions and verify the behaviors.

Control Flow Graph :  here the code is represented in graph form, control flow graph testing useful for conditionals statements.

control flow graph code

control flow graph code


For the first image is coding image and the second image is its graphical representation. Here A is having a value equal to 50 when A is become equal to 20 then its value should get printed. So when tester analyze the code and after understanding the whole code he will draw a graph which is shown in second image. And after that he will write a test cases which will exercise each condition. His test cases would be like

  1. Verify the response of the system when A has a value equal to 20.
  2. Verify the response of the system when A has a value equal to 30.
  3. Verify the response of the system when A has a value equal to 50.
  4. Verify the response of the system when A has a value equal to 1555.

This test cases will exercise almost every condition that are possible for the shown code.

Statement Coverage : Code is made of numbers of statement, statement coverage testing technique ensure that every statement present in code should get tested at least once. Statement coverage reduces the bug level up to a remarkable level.

Branch Coverage : We can consider a branch coverage as a sub type of Statement Coverage. Here in branch coverage, each and every loop, each if-else statement, and other conditional statements is tested.

1 comment: