White Box Testing and its Types
By Deep’stiLet us take a scenario where you go to the market to buy a cell phone.Before finalizing the cell phone, you check for the look and feel of the phone, features, technical specifications such as battery life, dimensions, color etc.Here what you are actually doing is testing the structure of the phone. Technically speaking, in this example, testing the structure of the cell phone is white box testing.
Here is an Image to give you an idea on types of white box testing and then we are discussing each of them one by one.

Please consider the following piece of code as an example for further understanding.

Fig 1.
Unit Testing
- Unit testing is a software testing technique in which the functionality of small software pieces is independently tested.
- Depending upon the system, these units could be the individual programs/ subprograms or a larger component.
- Testing focuses on only characteristics related to unit under testing.
- Developers can easily identify and make necessary changes to the source code of unit under testing.
- This testing involves programmers who wrote the code.
Drawbacks : If testing scope is too broad, developers does random testing, that’s risky, because each part of the system is not tested.
Statement Coverage Testing
- The benefit of statement coverage is its ability to identify which blocks of code have not been executed.
- This testing technique verifies whether each line of the code is executed at least once or not.
For above example:( Fig 1. )
- Require one test case for testing
- The IF statement must evaluate to TRUE
Drawbacks
- It does not check for decisions but is affected by computational statements.
- Thorough testing of Boolean expression is not possible.
- When if condition evaluates false, this code fails. (Refer code given below - Fig 2.)

Fig -2
Branch Coverage Testing
- Also known as Decision Coverage.
- This monitors whether every branch (decision point) has taken on every possible result.
- 2 passes are required for 100% branch coverage through an IF statement.
- 100% Branch Coverage = 100% Statement Coverage.
For above example ( Fig 1. )
- Requires two test case for testing.
- The IF statement evaluate to TRUE
- The IF statement evaluate to FALSE
Drawbacks: Decision coverage of object code is not ensured, through this testing
Condition Coverage Testing
- Also known as Predictive Coverage.
- Monitors whether every operand in a complex logical has taken on every True/False value.
- 100% Condition Coverage = 100% Branch Coverage
For above example: ( Fig 1. )
- Require 4 test case for testing
- Please refer the table below for the 4 conditions possible.

Mutation Testing
- The aim is to determine the test cases efficiency, by introducing a fault (mutant) into the code.
- If the test cases designed detect the mutant, this proves that the Test Cases are well designed, otherwise the test cases needs to be redesigned.
- Different types of Mutants:
- Killed Mutant: These are the faults injected, which are detected by Test Cases
- Alive/Live Mutant: These are the faults injected, which are not detected by Test Cases
- Stubborn Mutant: these are the faults injected, which no Test Cases can detect
Drawbacks of White Box Testing: –
For large systems exhaustive testing is impossible this means to test each and every path of large system is not possible Its time consuming Patience and complete knowledge of the code is required Detailed documentation is required
Conclusion on White Box Testing: -
The catch here is to understand the essence of what white box testing means and where it can be used. The more we understand in terms of practical example and can relate it the better control on performance you can attain.
Note: Unit tests tell you whether your code performed as expected, and code coverage tells you what remains to be tested.
|
|
|
About The Author of this article: Deepak and Diptee are one of the co-authors of this blog and writes majorly on software testing and more. You can read more of their articles here. |
Enjoyed this article? Download our Toolbar ( for Free ) and read us more quickly or Free Subscribe to the Full RSS Feed or Get Post like this in your Inbox Free Subscribe via Email







Its a very good.
sharan