0% found this document useful (0 votes)
68 views11 pages

Unit-2 (ST) - F

This document discusses different types of structural testing techniques used in software testing. It describes control flow testing, data flow testing, slice based testing, and mutation testing. It also discusses path testing, decision-to-decision paths, test coverage metrics, code coverage vs test coverage, and dataflow testing. The key advantages and types of structural testing are provided.

Uploaded by

rahu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views11 pages

Unit-2 (ST) - F

This document discusses different types of structural testing techniques used in software testing. It describes control flow testing, data flow testing, slice based testing, and mutation testing. It also discusses path testing, decision-to-decision paths, test coverage metrics, code coverage vs test coverage, and dataflow testing. The key advantages and types of structural testing are provided.

Uploaded by

rahu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Shivalik College of Engineering, Dehradun

Department of Computer Science and Engineering

Semester: 6th Software Testing: CS – 605


___________________________________________________________________________
Unit – 2

2.1 STRUCTURAL TESTING


Structural Testing is a type of software testing. This testing is used to test the internal design of the
software or the structure of the coding for the particular software. Structural testing uses white box
testing techniques.
Structural testing is a type of software testing which uses the internal design of the software for
testing or in other words the software testing which is performed by the team which knows the
development phase of the software, is known as structural testing.
Structural testing is basically related to the internal design and implementation of the software i.e.
it involves the development team members in the testing team. It basically tests different aspects
of the software according to its types. Structural testing is just the opposite of behavioral testing.

Types of Structural Testing:


There are 4 types of Structural Testing:

Control Flow Testing:


Control flow testing is a type of structural testing that uses the programs’s control flow as a model.
The entire code, design and structure of the software have to be known for this type of testing.
Often this type of testing is used by the developers to test their own code and implementation.
This method is used to test the logic of the code so that required result can be obtained.

Data Flow Testing:


It uses the control flow graph to explore the unreasonable things that can happen to data.
The detection of data flow anomalies are based on the associations between values and variables.
Without being initialized usage of variables. Initialized variables are not used once.

Slice Based Testing:


It is useful for software debugging, software maintenance, program understanding and
quantification of functional cohesion/structure. It divides the program into different slices and
tests that slice which can majorly affect the entire software.

Mutation Testing (modification):


Mutation Testing is a type of Software Testing that is performed to design new software tests and
also evaluate the quality of already existing software tests. Mutation testing is related to

__________________________________________________________________________________________
Prepared by: Prof. (Dr.) Kuldeep Chouhan 1
Shivalik College of Engineering, Dehradun
Department of Computer Science and Engineering

Semester: 6th Software Testing: CS – 605


___________________________________________________________________________
modification a program in small ways. It focuses to help the tester develop effective tests or locate
weaknesses in the test data used for the program.

Advantages of Structural Testing:


 It provides thorough testing of the software.
 It helps in finding out defects at an early stage.
 It helps in elimination of dead code.
 It is not time consuming as it is mostly automated.

Disadvantages of Structural Testing:


 It requires knowledge of the code to perform test.
 It requires training in the tool used for testing.
 Sometimes it is expensive.

Structural Testing Tools:


 JBehave
 Cucumber
 Junit
 Cfix

Note: Black box testing is a software testing methodology in which the tester analyzes the
functionality of an application without a thorough knowledge of its internal design. On the other hand,
in white box testing, the tester is knowledgeable of the internal design of the application and analyzes
it during testing.

2.2. Path Testing


Path Testing is a white-box testing technique based on the control structure of a program or a
module. Using this structure, a control flow graph is prepared and the various possible paths present
in the graph are executed as a part of testing. Therefore, by definition, Basis path testing is a
technique of selecting the paths in the control flow graph, that provide a basis set of execution
paths through the program or module. Since this testing is based on the control structure of the
program, it requires complete knowledge of the program’s structure. To design test cases using
this technique, four steps are followed:
1. Construct the Control Flow Graph
2. Compute the Cyclomatic Complexity of the Graph
3. Identify the Independent Paths
4. Design Test cases from Independent Paths

A control flow graph (or simply, flow graph) is a directed graph which represents the control
structure of a program or module. A control flow graph (V, E) has V number of nodes/vertices and
E number of edges in it. A control graph can also have:

 Junction Node – a node with more than one arrow entering it.
 Decision Node – a node with more than one arrow leaving it.
 Region – area bounded by edges and nodes (area outside the graph is also counted as a region.).

__________________________________________________________________________________________
Prepared by: Prof. (Dr.) Kuldeep Chouhan 2
Shivalik College of Engineering, Dehradun
Department of Computer Science and Engineering

Semester: 6th Software Testing: CS – 605


___________________________________________________________________________
2.3 DD-Paths
A decision-to-decision path, or DD-path, is a path of execution (usually through a flow graph
representing a program, such as a flow chart) between two decisions. More recent versions of the
concept also include the decisions themselves in their own DD-paths.

Below are the notations used while constructing a flow graph:

Figure: Sequential Statements

Figure: If – Then – Else

__________________________________________________________________________________________
Prepared by: Prof. (Dr.) Kuldeep Chouhan 3
Shivalik College of Engineering, Dehradun
Department of Computer Science and Engineering

Semester: 6th Software Testing: CS – 605


___________________________________________________________________________

Figure: Do while

Figure: Switch – Case

2.4 TEST COVERAGE METRICS


Test coverage is the method used to measure the percentage of test cases covering the entire
application code. It can determine the level of code testing to exercise on running the test cases. For
example, consider an application with 5,000 lines of code.

Test coverage criterion is a rule or a collection of rules that impose test requirements on a test set.
Test coverage level (of a test set T with respect to a set of test requirements TR) is the ratio of the
number of the test requirements in TR that are satisfied by T to the size of TR.

In other words, in software testing, test coverage is defined as a statistic that indicates the quantity
of testing completed by a collection of tests. It will entail obtaining information about which sections
of a program are executed when the test suite is performed in order to establish whether conditional
statement branches have been taken.

__________________________________________________________________________________________
Prepared by: Prof. (Dr.) Kuldeep Chouhan 4
Shivalik College of Engineering, Dehradun
Department of Computer Science and Engineering

Semester: 6th Software Testing: CS – 605


___________________________________________________________________________
It is a way for making sure that your tests are testing your code or how much of your code you
exercised by running the test.

Code Coverage and Test Coverage


Code coverage and test coverage are frequently mistaken. Even while the basic concepts are the
same, they are not the same.
 Code Coverage refers to unit testing procedures that must target all parts of the code at
least once and are performed by developers.
 Test Coverage, on the other hand, entails testing every requirement at least once and is
clearly the responsibility of the QA team.

Purpose of Test Coverage


 Identifying the region of a requirement that is not covered by a collection of test cases
 It aids in the creation of new test cases in order to enhance coverage.
 Developing a quantifiable metric of test coverage as an indirect technique of quality control
 Identifying useless test scenarios that do not contribute to increased coverage

Advantages of Test Coverage


 It can ensure the test's quality.
 It can aid in determining whether parts of the code were actually modified for release or
repair.
 It can aid in identifying untested pathways in your application.
 Prevent the spread of flaws.
 Time, scope, and cost may all be managed.
 Prevention of defects at an early point of the project's lifetime
 It can determine all of the application's decision points and pathways, allowing you to enhance
test coverage.
 Gaps in requirements, test cases, and problems at the unit and code levels may be easily
identified.

2.5 BASIS PATH TESTING


Given In Unit-1

2.6 DATAFLOW TESTING


Data Flow Testing is a type of structural testing. It is a method that is used to find the test paths of
a program according to the locations of definitions and uses of variables in the program. It has
nothing to do with data flow diagrams. It is concerned with:
 Statements where variables receive values,
 Statements where these values are used or referenced.

To illustrate the approach of data flow testing, assume that each statement in the program
assigned a unique statement number. For a statement number S-
DEF(S) = {X | statement S contains the definition of X}
USE(S) = {X | statement S contains the use of X}

If a statement is a loop or if condition, then its DEF set is empty and USE set is based on the
condition of statement s.

__________________________________________________________________________________________
Prepared by: Prof. (Dr.) Kuldeep Chouhan 5
Shivalik College of Engineering, Dehradun
Department of Computer Science and Engineering

Semester: 6th Software Testing: CS – 605


___________________________________________________________________________
Data Flow Testing uses the control flow graph to find the situations that can interrupt the flow of
the program. Reference or define anomalies in the flow of the data are detected at the time of
associations between values and variables. These anomalies/variances are:
 A variable is defined but not used or referenced,
 A variable is used but never defined,
 A variable is defined twice before it is used

Advantages of Data Flow Testing:


Data Flow Testing is used to find the following issues-
 To find a variable that is used but never defined,
 To find a variable that is defined but never used,
 To find a variable that is defined multiple times before it is use,
 Deallocating a variable before it is used.

Disadvantages of Data Flow Testing


 Time consuming and costly process
 Requires knowledge of programming languages.

Example:
1. read x, y; 2. if(x>y) 3. a = x+1 else 4. a = y-1 5. print a;

Control flow graph of above example:

Define/use of variables of above example:


Variable Defined at node Used at node

x 1 2, 3

y 1 2, 4

a 3, 4 5

__________________________________________________________________________________________
Prepared by: Prof. (Dr.) Kuldeep Chouhan 6
Shivalik College of Engineering, Dehradun
Department of Computer Science and Engineering

Semester: 6th Software Testing: CS – 605


___________________________________________________________________________
2.7 DEFINE/USE TESTING
Testing is the process of evaluating a system or its component(s) with the intent to find whether it
satisfies the specified requirements or not. In simple words, testing is executing a system in order to
identify any gaps, errors, or missing requirements in contrary to the actual requirements.
The user will select one or more items shown in the search results and he will add them to the cart.
After all this, he will check out. So this is an example of logically connected series of steps which the
user will perform in a system to accomplish the task.

Testing is the process of evaluating a system or its component(s) with the intent to find whether it
satisfies the specified requirements or not. In simple words, testing is executing a system in order to
identify any gaps, errors, or missing requirements in contrary to the actual requirements.
According to ANSI/IEEE 1059 standard, Testing can be defined as - A process of analyzing a software
item to detect the differences between existing and required conditions (that is defects/errors/bugs)
and to evaluate the features of the software item.

Why We Use Testing: Testing a product throughout its development lifecycle builds customer trust
and satisfaction, as it provides visibility into the product's strong and weak points. By the time
customers receive the product, it has been tried and tested multiple times and delivers on quality.

Who does Testing?


It depends on the process and the associated stakeholders of the project(s). In the IT industry, large
companies have a team with responsibilities to evaluate the developed software in context of the
given requirements. Moreover, developers also conduct testing which is called Unit Testing. In most
cases, the following professionals are involved in testing a system within their respective capacities −
 Software Tester
 Software Developer
 Project Lead/Manager
 End User

Different companies have different designations for people who test the software on the basis of their
experience and knowledge such as Software Tester, Software Quality Assurance Engineer, QA Analyst,
etc.

When to Start Testing?


An early start to testing reduces the cost and time to rework and produce error-free software that is
delivered to the client. However, in Software Development Life Cycle (SDLC), testing can be started
from the Requirements Gathering phase and continued till the deployment/utilization of the
software.
It also depends on the development model that is being used. For example, in the Waterfall model,
formal testing is conducted in the testing phase; but in the incremental model, testing is performed
at the end of every increment/iteration and the whole application is tested at the end.

Testing is done in different forms at every phase of SDLC −


 During the requirement gathering phase, the analysis and verification of requirements are
also considered as testing.
 Reviewing the design in the design phase with the intent to improve the design is also
considered as testing.
 Testing performed by a developer on completion of the code is also categorized as testing.

__________________________________________________________________________________________
Prepared by: Prof. (Dr.) Kuldeep Chouhan 7
Shivalik College of Engineering, Dehradun
Department of Computer Science and Engineering

Semester: 6th Software Testing: CS – 605


___________________________________________________________________________

When to Stop Testing?


It is difficult to determine when to stop testing, as testing is a never-ending process and no one can
claim that a software is 100% tested. The following aspects are to be considered for stopping the
testing process −
 Testing Deadlines
 Completion of test case execution
 Completion of functional and code coverage to a certain point
 Bug rate falls below a certain level and no high-priority bugs are identified
 Management decision

2.8 SLICE-BASED TESTING


In this, a slice of the program for testing particular test conditions or cases that may affect a value at
a particular point of interest.

Working Process: Slicing criteria are provided by the user.

Slicing or program slicing is a technique used in software testing which takes a slice or a group of
program statements in the program for testing particular test conditions or cases that may affect
a value at a particular point of interest. It can also be used for the purpose of debugging in order
to find the bugs more easily and quickly.

__________________________________________________________________________________________
Prepared by: Prof. (Dr.) Kuldeep Chouhan 8
Shivalik College of Engineering, Dehradun
Department of Computer Science and Engineering

Semester: 6th Software Testing: CS – 605


___________________________________________________________________________
(i) Static slicing:
(ii) A static slice of a program contains all statements that may affect the value of a variable
at any point for any random execution of the program.
(iii) Static slices are generally larger.
(iv) It considers every possible execution of the program.

(ii) Dynamic slicing:


 A dynamic slice of a program contains all the statements that actually affect the value of
a variable at any point for a particular execution of the program.
 Dynamic slices are generally smaller.
 Considers only a particular execution of the program.

2.9 RETROSPECTIVE ON STRUCTURAL TESTING


Structural testing, also known as glass box testing or white box testing is an approach where the tests
are derived from the knowledge of the software's structure or internal implementation.

For knowledge: The other names of structural testing include clear box testing, open box testing, logic
driven testing or path driven testing.

Structural Testing Techniques:


 Statement Coverage - This technique is aimed at exercising all programming statements with
minimal tests.
 Branch Coverage - This technique is running a series of tests to ensure that all branches are
tested at least once.
 Path Coverage - This technique corresponds to testing all possible paths which means that
each statement and branch are covered.

Advantages of Structural Testing:


 Forces test developer to reason carefully about implementation.
 Discloses errors in "hidden" code
 Spots the Dead Code or other issues with respect to best programming practices.

Disadvantages of Structural Box Testing:


 Expensive as one has to spend both time and money to perform white box testing.
 Every possibility that few lines of code is missed accidentally.
 Indepth knowledge about the programming language is necessary to perform white box
testing.

2.10 GAPS AND REDUNDANCIES


Gap in Software Testing: A gap analysis is a way of evaluating a business unit's performance to
evaluate whether or not business needs or objectives are being met, and if not, what measures
should be done to satisfy them.

Test Gap Analysis: Test Gap Analysis is the process of identifying these gaps where new code has
been deployed but hasn't been tested yet. This requires a combination of static analysis of all code
changes and dynamic analysis of all current testing. By comparing these two analyses, you can easily
see where any gaps are.
__________________________________________________________________________________________
Prepared by: Prof. (Dr.) Kuldeep Chouhan 9
Shivalik College of Engineering, Dehradun
Department of Computer Science and Engineering

Semester: 6th Software Testing: CS – 605


___________________________________________________________________________

Gaps in Process: Process gaps are inefficiencies and failures that make a business process less than
optimal. This could be due to an external factor—for example, having to prod a client or co-worker
for approval on a document—or an internal factor, such as an employee having to look up information
or enter data manually.

Redundancies in Software Testing: Informally, a software system is redundant when it performs the
same functionality through the execution of different elements. Redundancy has been extensively
exploited in many software engineering techniques, for example for fault-tolerance and reliability
engineering, and in self-adaptive and self-healing programs.
Redundancy is a system design in which a component is duplicated so if it fails there will be
a backup.

2.11 METRICS FOR METHOD EVALUATION


 A Metric is a degree to which a system or its components retains/hold a given
attribute/features.
 Testers don't define a metric just for the sake of documentation. For e.g. developers can
apply a metric to assume the time it takes to develop software. It can also be assigned to
determine the numbers of new features and modifications, etc., added to the software.

Importance of Software Testing Metrics


As mentioned, test metrics are crucial to measuring the quality and performance of the software.
With proper software testing metrics, developers can−
 Determine what types of improvements are required to deliver a defect-free, quality
software
 Make sound decisions about the subsequent testing phases, such as scheduling upcoming
projects as well as estimating the overall cost of those projects
 Evaluate the current technology or process and check whether it needs further modifications

Types of software testing metrics


There are three types of software testing metrics−
 Process Metrics: Process metrics define the characteristics and execution of a project. These
characteristics are essential to the improvement and maintenance of the process in the SDLC
(Software Development Life Cycle).
 Product Metrics: Product metrics define the size, design, performance, quality, and
complexity of a product. By using these characteristics, developers can enhance their
software development quality.
 Project Metrics: Project Metrics determine the overall quality of a project. It is used to
calculate costs, productivity, defects and estimate the resource and deliverables of a project.
It is incredibly vital to identify the correct testing metrics for the process.

Most used Metrics


Below are the types of metrics, popularly used by developers and testers
 Defect metrics: This metric allows developers to understand the various quality aspects of
software, including functionality, performance, installation stability, usability, compatibility,
etc.
 Defects finding rate: It is used to identify the pattern of defects during a specific timeframe
 Defect severity: It enables the developer to understand how the defect is going to impact the
quality of the software.
__________________________________________________________________________________________
Prepared by: Prof. (Dr.) Kuldeep Chouhan 10
Shivalik College of Engineering, Dehradun
Department of Computer Science and Engineering

Semester: 6th Software Testing: CS – 605


___________________________________________________________________________
 Defect cause: It is used to understand the root cause of the defect.
 Test Coverage: It defines how many test cases are assigned to the program. This metric
ensures the testing is conducted to its full completion. It further aids in checking the code
flow and test functionalities.
 Defect fixing time: It determines the amount of time it takes to resolve a defect
 Test case efficiency: It tells the efficiency rate of test cases in finding defects
 Schedule adherence: Its primary motive is to figure out the time difference between the
planned schedule and the actual time of executing a schedule.

__________________________________________________________________________________________
Prepared by: Prof. (Dr.) Kuldeep Chouhan 11

You might also like