Structural testing

Structural testing

Last updated on

Software must be thoroughly tested before its release or implementation into an existing application. The tests ensure that the production environment is defect free. There are different software testing techniques, and structural testing is one of them. Structural testing aims at verifying the internal architecture or the implementation of the system.

What is Structural testing?

Structural testing is a type of software testing that tests the software’s internal design or code structure. In simple words, the complete code of the application is tested. Test cases are written after thoroughly understanding interior design and code architecture.

It determines how the system works and is often referred to as white-box testing, glass-box, or clear-box testing. It examines the code flows, module integrations, and transfer of data variables from one module to look for any defects. 

To perform structural testing, testers must understand the code’s internal execution thoroughly. Therefore, it involves developers in the testing team who are well-versed with code and aware of the user flow system performance. Structural testing applies to all testing levels. However, the structures are different for different levels.

Characteristics of Structural Testing

  1. It requires in-depth knowledge of the software’s internal code. Hence, usually, the developer well-versed in the system performs the testing.

  2. It is based on how the system works or performs rather than its functionality or how the users perceive it.

  3. Its quality heavily relies on the expertise of the tester or developer developing the test scripts.

Types of Structural Testing

  1. Mutation Testing
  • In mutation testing, a mutant or a small error is intentionally introduced in the system to test the efficacy of the test scripts. If the test script identifies the error, it is considered successful.
  • It aims to design new test cases and improve the quality of existing test cases to deliver a high-quality product.
  • Mutation testing checks the effectiveness and quality of the defined test cases.

  1. Data Flow testing
  • Data flow testing is based on the values of data and their usage in the program.
  • It uses a control flow graph to find anomalies that can interrupt data flow.
  • With the association of values and variables, irregularities in the data flow are detected.
  • This testing traces the relationship among data values throughout a specific execution path.

  1. Control flow testing
  • Control flow testing is the basis of structural testing that uses a program’s control flow as a model.
  • Through control flow graphs, it determines the execution of code statements.
  • Test cases are written by selecting a specific segment of the code flow.
  • To perform this kind of testing, testers require a complete understanding of the software’s entire code, structure, and logic.

  1. Slice-based testing
  • As the name suggests, this testing technique is based on slices. Slice-based testing divides the code into small modules called slices that impact specific values at a certain point.
  • Weiser and Gallagher first proposed the methodology for software maintenance.
  • This approach aims to break the code into small chunks and evaluate each piece accurately.
  • Slice-based testing is useful for software maintenance, debugging, and program understanding.

Structural testing techniques

Structural testing can be performed using several techniques. Each technique differs in certain approaches that set it apart from others.

  1. Statement Coverage

This technique aims to perform tests on all the code statements with the least possible tests. This testing removes all the errors in each statement. This technique is not suitable for testing the control flow. 

To test every executable statement at least once, developers must ensure 100% coverage. In simple terms, higher coverage means a lesser chance of missing out on bugs.

  1. Path Coverage

As the name suggests, every possible path(including entry and exit) in the code is tested. This means each statement and branch is covered. The aim is to discover all combinations of possible paths and test them at least once.

The level of coverage is detailed and more time-consuming compared to other structural testing techniques. However, this can be prevented by using cyclomatic complexity that locates redundant test cases and removes them.

  1. Branch Coverage

Branch coverage tests all the edges or branches of the code at least once to find any potential error. In case of any error, developers must fix it as soon as possible.

It involves testing points in branches of the control graph. Each result is tested at each decision level at least once to achieve 100% coverage. The results are boolean.

  1. Condition

The main aim is to test all potential combinations of conditions, including the one missed in branch coverage. It provides coverage and addresses issues better than branch coverage. 

One major drawback of conditional coverage is the growing exponential condition due to many combinations that must be ignored.


  • It is automated, so it doesn’t require much time and human interference.
  • Identification of defects or errors at an early stage enables smooth execution.
  • Execution of structural testing easily detects and removes extra code or dead code.
  • It provides thorough testing of the software and the internal code.


  • To perform structural testing, in-depth knowledge of the code is required.
  • Although the testing process is automated, structural testing tools are complicated. Trained professionals can only use these testing tools.
  • There also may be a chance to miss out on lines or statements, resulting in big trouble.
  • It can be expensive as structural testing often requires resources.

Structural testing tools

Some of the commonly used tools for structural testing are:

  1. Cucumber- This tool evaluates system behavior. Using this tool, developers can create testing scripts to perform automated testing and system acceptance.
  1. JBehave- JBehave is a BDD(behavior-driven development) tool executed in Java programming language. It is intended to make the BDD process more spontaneous and smooth.
  1. Cfix- A XUnit structural testing tool supported by C/C++ languages. It works well with Windows debuggers such as Visual Studio and WinDBG.
  1. JUnit- It is an open-source unit testing framework written in Java.

Summing up

Structural testing is a software testing technique that tests the code structure. It helps to identify the important components in the code flow. It focuses on how the system works rather than its functionality. 

This testing is the opposite of behavioral testing, which focuses on the output. In this blog, we have covered the different topics that one may know related to structural testing. We have also discussed the different structural testing techniques and how they are different from each other.

Leave a Comment