Software Testing – White Box Testing

White Box Testing – Definition

White box testing is testing that is based on the internal structure of a systems code and can also be known as glass box testing, clear box testing or structural testing. White box testing typically takes place at unit level and focuses on internal system testing.

For effective white box testing, it is important to have an understanding of the back-end of a system as well as sound programming skills. Without these, it won’t be possible to produce appropriate test cases.

This section of the document will discuss the applications of white box testing, the approach to white box testing, the processes involved, the various techniques that can be used for white box testing and the advantages / disadvantages of it.

White Box Testing – Applications

White box testing can be best used to test for any of the following:

  • Security flaws.
  • Badly designed process flows in the code.
  • How particular inputs flow through the code.
  • The practicality of conditional statements and loops in the application code.
White Box Testing – Approach / Process

White box testing can be simplified down into two steps:

  1. Understanding the source code
  2. Creating and executing the test cases.
White Box Testing – Understanding the Source Code

To effectively carry out white box testing, the tester first needs to learn about and gain a decent understanding of the system source code. Because white box testing requires working with the internal structure of the application, it is important that the tester is apt in using the programming languages that were employed to build the system. Furthermore, the tester must have a deep understanding of a secure programming process, as security is usually an important factor of software application testing.

White Box Testing – Creating and carrying out the Test Cases

Once an understanding of the source code has been gained, the code can actually be tested. The aim of white box testing is primarily to test that the code flows properly and is correctly structured. White box tests can sometimes be carried out by writing additional little snippets of code to test the source code. The job of the tester is to develop tests for every process in the application. Due to the requirement of a good understanding of the application code, white box testing is most commonly carried out by developers. Other approaches to the test cases include manual testing, trial and error testing and using testing tools.

White Box Testing – Techniques

There are 3 core techniques that white box testing focuses on. They are:

  • Statement Coverage
  • Branch Coverage
  • Path Coverage
White Box Testing – Statement Coverage

This is a white box testing technique that makes sure all individual executable statements in the application codebase are tested at least once. The aim of the statement coverage technique is to remove or fix any unused or missing statements from the code.

White Box Testing – Branch Coverage

Branch coverage is a technique with the purpose of ensuring that every possible branch from each conditional decision point in the code is executed at least once. This in turn tests all branches by ensuring that each is executed. The branch coverage technique is particularly useful for testing nested blocks of code and helps by checking that the branches do not lead to unusual behaviour from the application.

White Box Testing – Path Coverage

The path coverage testing technique focuses on creating test cases that all follow linearly independent paths through the program. The aim is to cover all possible linear paths in the application code. To create the test cases for path coverage testing, the testers would usually draw a control flow diagram which helps to visualise the different linear paths.

The tester will then write unit tests that aim to execute all of the paths through the control flow. The aim of the test is to determine if any paths aren’t working, are unnecessary or are inefficient.

White Box Testing – Advantages

There are various advantages involved in white box testing. They include:

  • White box testing digs deep and can allow for code optimization due to the hidden errors being uncovered.
  • White box testing covers all possible paths through an application which allows for through testing.
  • White box testing test cases can usually be automated.
  • The additional knowledge and understanding of the testers also allows for much more in depth testing.
  • White box testing is a very efficient way of finding errors in software applications.
White Box Testing – Disadvantages

There are also some disadvantages associated with white box testing, including:

  • The complexity of white box testing can make it quite a costly process.
  • Generally, developers do not like testing.
  • White box testing is quite time consuming. Large systems will take a considerable amount of time to test.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: