EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Software Development Software Development Tutorials Software Testing Tutorial Structural Testing
 

Structural Testing

Priya Pedamkar
Article byPriya Pedamkar

Updated April 3, 2023

Structural Testing

 

 

Introduction to Structural Testing

Structural Testing is a type of testing in which the complete code of the application is tested. This is different from the other type testing which black box where the main concentration is on the type of output generated rather than the way the output generated.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

when the software is developed it is expected to be tested from all the aspects so that the production environment is defects free. There are different testing strategies and structural testing is one of them. In software testing basically the outputs are generally matched with the expected output.

There are two main methodologies of two testing’s and they are often referred to as white-box testing and black-box testing. Structural testing is generally a white box testing where the main consideration is on the structure of the code. In the black box testing, the output result is compared with expected result but how the output or what is the code that generated the output is not tested. This testing is taken care of by the structural testing.

Structural Testing with Diagram

Structural Testing1

Since here the code is being tested it is expected that the associate who is testing has a good understanding of the programing language in which the code has been written. The structural testing is concentrated on how the system is doing rather than the functionality of the system. Thus this testing is just the opposite of behavioral testing. Most of the time structural testing is also referred to as white Box Testing and also as open, transparent or glass testing basing on the code.

We can see the above diagram. With white box testing, we are passing the input and we are monitoring that who the input is traversing and being acted upon to generate the output. This is not the case with the black box testing as it is the mainly considering that the output is as per expectation of the functional requirement. In a way, all the standards of the code and associated risks get captured in the structural testing only.

Now let us see a few of the techniques of structural testing. Below are a few structural techniques.

  • Statement Coverage
  • Path Coverage
  • Branch Coverage
  • Condition

1. Statement Coverage

The main aim of this technique of structural testing is to make sure all the statements of the code gets tested. The adequacy criterion should be 1 which makes sure that we have 100% coverage. This good in testing each statement or part but this technique not good in testing the control flow. This can be illustrated from below diagram

Statement Coverage

In the above diagram N1, N2, N3, N4, N5 will be basic blocks to be tested and E1 to E5 represents the edges. This N1-N5 is sequences of the statements and E1- E5 are edges that indicates the control flow. Now in statement coverage, the nodes will be covered by below two steps

E1 -> E2 -> E5 E1 -> E3

you can see that the E4 is missed which is control flow. N3 is having two exits E5 and E4 but since N4 block or statement is already covered by E3, E4 will not be covered and hence one E5 will be taken from N3. This is one flaw in statement coverage.

2. Path Coverage

These techniques supposedly used to tests different paths from entry to exit points without a miss and this can be different combinations of decisions taken in the sequence. Some time path can be too many to be tested such as in case of larger loops. This can be avoided by adopting cyclomatic complexity that helps in identifying the redundant test cases and eliminate them. Thus we can test linearly the independent paths using cyclomatic complexity in path coverage.

3. Branch Coverage

Branch coverage aims to test all the edges or branches of the code. Thus the E4 that was getting missed as part of statement coverage will be covered here. Thus branch covaerhe provide better solution to coverage testing by solving the shortcoming of statement covergae. Let us look at below diagram to get better understanding of branch coverage.

Branch Coverage

here full 100% branch coverage is provided by following E1 -> E2

E3

but we can see that E1 is a TRUE branch and we can obtain TRUE conditions by multiple conditions. But branch test main aim to test each branch once. This E1 which an evaluate True on multiple conditions such as (A>2 [True] and B>8 [False]. This evaluates E1 as True) or (A<2 [False] and B<8 [True] which again evaluates E1 as True). This short come is tested in conditional coverage.

4. Conditional Coverage

The main aim of this techniques are to test all the possible combinations of conditions along with that of the one, we missed in branch coverage. Thus even though this looks like an extension of branch coverage, it provides better coverage. But there is one problem associated with conditional coverage and that is getting exponentially increased conditions due to numerous combinations that need to be avoided.

Advantages and Disadvantages of Structural Testing

Below are the advantages and disadvantages:

Advantages

Below are the advantages:

  • It provides thorough testing of the code and finally the software
  • All the early defects can easily be identified
  • It eliminates the dead code or statements
  • The steps of structural can be automated if you have time
  • Translational errors while typing, unwanted Risks with the data and other technical standards can easily be validated with this testing

Disadvantages

Below are the disadvantages:

  • There are few shortcomings in each technique as discussed in each coverage even though there are alternates
  • Heavy dependency on the skill set of the tester as thee code component is tested
  • Since this is more detailed testing, it is quite

Conclusion

Thus in this article we have seen the structural testing in detail like what are the different techniques and how are they different from each other. We also got answers for how structural testing is different from behavioral testing etc. This if the project is hugely critical and the user does not want to take any chance then they opt for structural testing as it more robust testing.

Recommended Articles

This is a guide to Structural Testing. Here we discuss an introduction to Structural Testing along with techniques and block diagrams. You can also go through our other related articles to learn more –

  1. Automation Testing Life Cycle
  2. Dynamic Testing
  3. Manual Testing
  4. Static Testing

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW