What is White Box Testing? Techniques, Examples and Types

What is White Box Testing? Techniques, Examples and Types

Henry Mills


Software development life cycles are incomplete without software testing. Software testing plays a major role in ensuring the quality and proper functioning of your software product. There are two ways in which software testing can be carried out.

White box testing: Line to line testing of the code

Black box testing: Based on inputs and outputs.

In this article, we will read in detail about the white box testing.

What is White Box Testing?

Also referred to as clear, glass box or structural testing. It is a testing method that tests the internal structure of an application. As opposed to black-box testing, it does not focus on the functionality but involves line to line assessment of the code.

In white box testing, the tester has to go through the code line by line to ensure that internal operations are executed as per the specification and all internal modules are properly implemented.

White Box Testing Coverage


  1. Code coverage: It aims at testing the complete code.
  2. Segment coverage: Segment coverage confirms that every code statement is executed once while performing the testing process.
  3. Branch Coverage or Node Testing: Branch Coverage or Node Testing confirms that every code branch is executed once while testing.
  4. Compound Condition Coverage: compound condition coverage is a type of white box coverage with multiple test conditions each having multiple paths and combination to fulfill the condition.
  5. Basis Path Testing: every independent path is considered under basic path testing.
  6. Data Flow Testing : data flow testing deals with the data variable and tracks them to verify its use. They unveil the bugs relating variable initialize, declaration but not used, and so on.
  7. Path Testing: Path testing covers all the probable paths in the code.
  8. Loop Testing: Loop testing ensures the coverage of single loops, concatenated loops, and nested loops in the code.

Read more: Top 11 WordPress Plugins For Developers and Testers

Why We Use White Box Testing?

To ensure:

  • That all the paths are covered at least once.
  • All logical decisions are based on true and false values.
  • To test that all loops are tested

To discover the following types of bugs:

  • Logical errors
  • The design errors
  • Typographical errors
  • Syntax errors

Do Testers Require Programming Skills to Conduct White Box Testing?

As a tester, you will require to create test cases to cover the program logic completely. And hence you will require good programming skills for testing.

Limitations

Testing each and every path of the loop from a large system is very exhaustive and hence is not possible. But you can select the important paths and test them to get desired results.

Difference Between White Box Testing and Black Box Testing

Both of them are two major classifications of software testing. They are very different from each other.

  1. White box testing refers to the line by line testing of the code, while black box testing refers to giving the input to the code and validating the output.
  2. Black box testing refers to testing the software from a user’s point of view, whereas the White box refers to the testing of the actual code.
  3. In Black box testing, testing is not concerned about the internal code, but in WBT testing is based on the internal code.
  4. Both the developers and testers use white box testing. It helps them validate the proper working of every line of the code.

Steps to Perform White Box Testing

Step #1 – Learn about the functionality of the code. As a tester, you have to be well versed in programming language, testing tools, and various software development techniques.

Step #2– Develop the test cases and execute them.

Types of White Box Testing

White box testing includes various types of testing, some of them are:

  • Unit Testing: Unit testing is testing of a single unit to find defects. It is usually done by the developers to detect bugs in the code developed. It is usually the first round of testing.
  • Testing for Memory Leaks: Memory leaks can take away all the credibility of the code, making it works slower. An experienced tester tests the code for the memory leaks detecting the actual leak point.
  •  Penetration Testing: with a detailed understanding of the code, and thorough network info, IP addresses, and all server info. The main aim of this testing is to expose the code to find its vulnerability to security threats.

Read more: How the best software QA testers can truly own their projects

Techniques of White Box Testing

  1. Statement Coverage
  2. Branch Coverage
  3. Path Coverage

These techniques do not find bugs in the code but detect the path, statements, and branches that are not covered during testing.

  • Statement Coverage: It ensures whether each and every line of the code is executed at least once during testing.
  • Branch Coverage: Branch Coverage ensures that every branch from each decision point is executed.
  • Path Coverage: Path coverage ensures that every path is traversed at least once. This technique is used for testing complex programs.

White Box Testing Example

Let us consider the following code snippet:

INPUT A & B

C = A + B

IF C>100

PRINT “ITS DONE”

Now in the first, line, we assign the value of A and B. Let us suppose A = 60 and B = 50. Moving on to the second line, now C is assigned a value of A+B, here A = 60 and B = 50, hence C = 110. Moving on to the third line, we will check if C > 100, here the condition is true and hence we should get our result as ITS DONE

White Box Testing Tools

#1) Veracode

Veracode is a prominent toolkit that helps in identifying and resolving the defects quickly, economically and easily. It supports various programming languages like .NET, C++, JAVA, etc. It also supports security testing.

#2) EclEmma

EclEmma is a free Java code coverage tool. It has various features that ease the testing process. It is widely used by the testers to conduct white box testing on their code.

#3) RCUNIT 

It is free to use tool for testing C programs.

#4) cfix

It is a framework for testing C/C++ codes. It makes the complete process of developing test suites simple and easy. It is specifically designed for NT Kernel mode and Win32.

#5) Googletest 

This C++ test framework by Google has an extensive list of features including test Discovery, Death tests, Value-parameterized tests, fatal & non-fatal failures, XML test report generation, etc. It supports various platforms like Linux, Windows, Symbian, Mac OS X, etc.

#6) EMMA

A perfect tool for programs based on JAVA code. It comes with various useful features to assists testers in testing their code.

The list doesn’t end here. However, listed here are the most used/prominent ones.

Advantages of White Box Testing 

  • Code optimization
  • Transparency of the internal coding structure
  • Thorough testing by covering all possible paths of a code
  • Introspection of the code by the programmers
  • Easy test case automation

Read more: 11 Software Testing Techniques To Look For in 2019

Disadvantages of White Box Testing 

  • A complex and expensive procedure
  • Frequent updating of the test script is required whenever changer happens in the code
  • Exhaustive testing for large-sized application
  • Not always possible to test all the conditions.
  • Need to create a full range of inputs making it a very time-consuming process

Conclusion

White box testing is a predominantly used software testing technique. It is based on evaluating the code to test which line of the code is causing the error. The process requires good programming language skills and is generally carried out by both developers and testers.

← Prev . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Next →


Report Page