White Box Testing and its Types

By Deep’sti

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

Types of White box testing diagram

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

Example for White Box testing

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

statement coverage example for white box testing

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.

Parameters table for white box testing

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.


Email Print
Vote This Post DownVote This Post Up (+4 rating, 1 votes)
Loading ... Loading ...

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


  • Tags: , , , , , , , ,
  • Read More Stories from software testing

  • One Response to “White Box Testing and its Types

    Click Me and Jump to Add your Comment :)

    1 Comments from Friends and Readers

    • Sharanagouda, June 19, 2008:

      Hi..
      Its a very good.
      sharan

    Leave a comment Share your thoughts with the world

    Scroll Down and Check footer for more details



    • Recent Comments:

      • Anurag: Great Tool… Thnx For thepost….. http://www.pcdrome.com
      • CypherHackz: But, is it secure? Nowadayas I keep thinking about the security of the information transfered from my PC...
      • Greg P.: I read up about DropBox on their website. This looks very promising! I especially like the differential sync...
      • dave: I have heard many good things about dropbox and signed up for beta but did not get an invite. May I get an...
      • drew: i want the engage xp theme please how would i get it!!!
      • brandub: thanks for ths, I was searching for something else but this process helped me a little bit, and is...
      • Gene: This looks great! Do you have any invites left? Thanks!
      • dyjay: helow! how can i play wars of gears after instal dx 10 from alky on xp?i have a error ’send….don`t...
      • Madhur Kapoor: My father will love this.
      • kali: i dont knw john i ve downloaded immediately as chrome was lainched….i didnt experience any of the probs u...

    Technology Blogs - Blog Top Sites