0% found this document useful (0 votes)
19 views132 pages

Software Testing Methodologies

This document provides lecture notes on software testing methodologies. It discusses the objectives of software testing, including understanding fundamental concepts, types of testing, and testing levels. It also covers topics like black box and white box testing, unit testing, integration testing, regression testing and system testing. The document outlines different testing methodologies like flow graph testing, transaction flow testing, data flow testing, domain testing, path testing, logic based testing, state testing and graph matrices. The overall goal is to learn techniques to systematically test software and identify bugs at different stages of development.
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)
19 views132 pages

Software Testing Methodologies

This document provides lecture notes on software testing methodologies. It discusses the objectives of software testing, including understanding fundamental concepts, types of testing, and testing levels. It also covers topics like black box and white box testing, unit testing, integration testing, regression testing and system testing. The document outlines different testing methodologies like flow graph testing, transaction flow testing, data flow testing, domain testing, path testing, logic based testing, state testing and graph matrices. The overall goal is to learn techniques to systematically test software and identify bugs at different stages of development.
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/ 132

lOMoARcPSD|28021796

Software Testing Methodologies

Software testing and automation (Anna University)

Studocu is not sponsored or endorsed by any college or university


Downloaded by Janani Ramannachetty ([email protected])
lOMoARcPSD|28021796

SOFTWARE
TESTING
METHODOLOGIES
LECTURE notes

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

III Year B. Tech. CSE –II Sem L T/P/D C


4 1/- / - 3
SOFTWARE TESTING METHODOLOGIES
Objec琀椀ves:
 To study the fundamental concepts of so昀琀ware tes琀椀ng which includes
objec琀椀ves, process, criteria, strategies, and methods.
 To discuss various so昀琀ware tes琀椀ng types and levels of tes琀椀ng like black
and white box tes琀椀ng along with levels unit test, integra琀椀on,
regression, and system tes琀椀ng.
 It also helps to learn the types of bugs, tes琀椀ng levels with which the
student can very well iden琀椀fy a bug and correct as when it happens.
 It provides knowledge on transac琀椀on 昀氀ow tes琀椀ng and data 昀氀ow tes琀椀ng
techniques so that the 昀氀ow of the program is tested as well.
 To learn the domain tes琀椀ng, path tes琀椀ng and logic based tes琀椀ng to
explore the tes琀椀ng process easier.

Syllabus
UNIT-I
Introduc琀椀on:-Purpose of tes琀椀ng,Dichotomies,model for tes琀椀ng,consequences of bugs,
taxonomy of bugs,Flow graphs and Path tes琀椀ng:- Basics concepts of path tes琀椀ng,
predicates, path predicates and achievable paths, path sensi琀椀zing, path
instrumenta琀椀on, applica琀椀on of path tes琀椀ng.

UNIT-II
Transac琀椀on Flow Tes琀椀ng:-transac琀椀on 昀氀ows, transac琀椀on 昀氀ow tes琀椀ng techniques.
Data昀氀ow tes琀椀ng:- Basics of data昀氀ow tes琀椀ng, strategies in data昀氀ow tes琀椀ng,applica琀椀on of
data昀氀ow tes琀椀ng.

UNIT-III
Domain Tes琀椀ng:-domains and paths, Nice & ugly domains, domain tes琀椀ng, domains
and interfaces tes琀椀ng, domain and interface tes琀椀ng, domains and testability.

UNIT-IV:
Paths,Path products and Regular expressions:- path products &pathexpression,
reduc琀椀on procedure, applica琀椀ons, regular expressions & 昀氀ow anomaly detec琀椀on.
Logic Based Tes琀椀ng:-overview,decision tables,path expressions,kv charts,
speci昀椀ca琀椀ons.

UNIT-V:
State, State Graphs and Transi琀椀on tes琀椀ng:- state graphs, good & bad state graphs,
state tes琀椀ng, Testability 琀椀ps.
Graph Matrices and Applica琀椀on:-Mo琀椀va琀椀onal overview, matrix of graph,
rela琀椀ons, power of a matrix, node reduc琀椀on algorithm, building tools

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

TEXT BOOKS
1. So昀琀ware Tes琀椀ng techniques – Boris Beizer, Dreamtech, second edi琀椀on.
2. So昀琀ware Tes琀椀ng Tools – Dr.K.V.K.K.Prasad, Dreamtech.

REFERENCES BOOKS:
1. The cra昀琀 of so昀琀ware tes琀椀ng – Brian Marick, Pearson Educa琀椀on.
2. So昀琀ware Tes琀椀ng Techniques – SPD(Oreille)
3. So昀琀ware Tes琀椀ng in the Real World – Edward Kit, Pearson.
4. E昀昀ec琀椀ve methods of So昀琀ware Tes琀椀ng, Perry, John Wiley.
5. Art of So昀琀ware Tes琀椀ng – Meyers, John Wiley.

OUTCOMES

 Know the basic concepts of software testing and its essentials.


 Able to iden琀椀fy the various bugs and correc琀椀ng them a昀琀er knowing the consequences
of the bug.
 Use of program’s control 昀氀ow as a structural model is the corner stone of tes琀椀ng.
 Performing func琀椀onal tes琀椀ng using control 昀氀ow and transac琀椀on 昀氀ow graphs.

INDEX

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

UNIT NO TOPIC PAGE NO

Introduc琀椀on 1-2

I
Dichotomies,consequences of Bugs, Taxonomy 3-14
of bugs
Flow graphs and Path tes琀椀ng 14-33

Transac琀椀on Flow Tes琀椀ng 34-36


II

Data昀氀ow tes琀椀ng 37-50

III Domain Tes琀椀ng 51-68

Paths, Path products & Regular xpressions 69-92


IV
Logic Based Tes琀椀ng 93-106

107-113
State, State Graphs and Transi琀椀on tes琀椀ng
V

Graph Matrices 114-119

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

UNIT- I
UNIT-I

Introduc琀椀on:-Purpose of tes琀椀ng,Dichotomies,model for tes琀椀ng,consequences of bugs, taxonomy of


bugs,Flow graphs and Path tes琀椀ng:- Basics concepts of path tes琀椀ng, predicates, path predicates
and achievable paths, path sensi琀椀zing, path instrumenta琀椀on, applica琀椀on of path tes琀椀ng.

What is tes琀椀ng?

Tes琀椀ng is the process of exercising or evalua琀椀ng a system or system components by manual or automated means to
verify that it sa琀椀s昀椀es speci昀椀ed requirements.

The Purpose of Testing

Tes琀椀ng consumes at least half of the 琀椀me and work required to produce a func琀椀onal program.
o MYTH: Good programmers write code without bugs. (It’s wrong!!!)
o History says that even well wri琀琀en programs s琀椀ll have 1-3 bugs per hundred statements.

Productivity and Quality in Software:

o In produc琀椀on of consumer goods and other products, every manufacturing stage is


subjected to quality control and tes琀椀ng from component to 昀椀nal stage.
o If 昀氀aws are discovered at any stage, the product is either discarded or cycled back for
rework and correc琀椀on.
o Produc琀椀vity is measured by the sum of the costs of the material, the rework, and the
discarded components, and the cost of quality assurance and tes琀椀ng.
o There is a tradeo昀昀 between quality assurance costs and manufacturing costs: If
su昀케cient 琀椀me is not spent in quality assurance, the reject rate will be high and so will
be the net cost. If inspec琀椀on is good and all errors are caught as they occur, inspec琀椀on
costs will dominate, and again the net cost will su昀昀er.
o Tes琀椀ng and Quality assurance costs for 'manufactured' items can be as low as 2% in
consumer products or as high as 80% in products such as space-ships, nuclear reactors,
and aircra昀琀s, where failures threaten life. Whereas the manufacturing cost of so昀琀ware
is trivial.
o The biggest part of so昀琀ware cost is the cost of bugs: the cost of detec琀椀ng them, the
cost of correc琀椀ng them, the cost of designing tests that discover them, and the cost of
running those tests.
o For so昀琀ware, quality and produc琀椀vity are indis琀椀nguishable because the cost of a
so昀琀ware copy is trivial.
1

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

o Tes琀椀ng and Test Design are parts of quality assurance should also focus on bug
preven琀椀on. A prevented bug is be琀琀er than a detected and corrected bug.
Phases in a tester's mental life:

Phases in a tester's mental life can be categorized into the following 5 phases:

1. Phase 0: (Un琀椀l 1956: Debugging Oriented) There is no di昀昀erence between tes琀椀ng and
debugging. Phase 0 thinking was the norm in early days of so昀琀ware development 琀椀ll
tes琀椀ng emerged as a discipline.
2. Phase 1: (1957-1978: Demonstra琀椀on Oriented) the purpose of tes琀椀ng here is to show that
so昀琀ware works. Highlighted during the late 1970s. This failed because the probability of
showing that so昀琀ware works 'decreases' as tes琀椀ng increases. I.e. the more you test, the
more likely you will 昀椀nd a bug.
3. Phase 2: (1979-1982: Destruc琀椀on Oriented) the purpose of tes琀椀ng is to show that
so昀琀ware doesn’t work. This also failed because the so昀琀ware will never get released as you
will 昀椀nd one bug or the other. Also, a bug corrected may also lead to another bug.
4. Phase 3: (1983-1987: Evalua琀椀on Oriented) the purpose of tes琀椀ng is not to prove anything
but to reduce the perceived risk of not working to an acceptable value (Sta琀椀s琀椀cal Quality
Control). No琀椀on is that tes琀椀ng does improve the product to the extent that tes琀椀ng catches
bugs and to the extent that those bugs are 昀椀xed. The product is released when the
con昀椀dence on that product is high enough. (Note: This is applied to large so昀琀ware
products with millions of code and years of use.)
5. Phase 4: (1988-2000: Preven琀椀on Oriented) Testability is the factor considered here. One
reason is to reduce the labor of tes琀椀ng. Other reason is to check the testable and non-
testable code. Testable code has fewer bugs than the code that's hard to test. Iden琀椀fying
the tes琀椀ng techniques to test the code is the main key here.

Test Design:

We know that the so昀琀ware code must be designed and tested, but many appear to be unaware that tests
themselves must be designed and tested. Tests should be properly designed and tested before applying it to the
actual code.

Testing isn’t everything:


There are approaches other than tes琀椀ng to create be琀琀er so昀琀ware. Methods other than tes琀椀ng include:

1. Inspec琀椀on Methods: Methods like walkthroughs, desk checking, formal inspec琀椀ons and
code reading appear to be as e昀昀ec琀椀ve as tes琀椀ng but the bugs caught don’t completely
overlap.

2. Design Style: While designing the so昀琀ware itself, adop琀椀ng stylis琀椀c objec琀椀ves such as
testability, openness and clarity can do much to prevent bugs.
3. Sta琀椀c Analysis Methods: Includes formal analysis of source code during compila琀椀on. In

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

earlier days, it is a rou琀椀ne job of the programmer to do that. Now, the compilers have
taken over that job.
4. Languages: The source language can help reduce certain kinds of bugs. Programmers
昀椀nd new bugs while using new languages.
5. Development Methodologies and Development Environment: The development
process and the environment in which that methodology is embedded can prevent
many kinds of bugs.

Dichotomies:

 Tes琀椀ng Versus Debugging:


Many people consider both as same. Purpose of tes琀椀ng is to show that a program has bugs. The purpose
of tes琀椀ng is to 昀椀nd the error or misconcep琀椀on that led to the program's failure and to design and
implement the program changes that correct the error.
Debugging usually follows tes琀椀ng, but they di昀昀er as to goals, methods and most important psychology.
The below tab le shows few important di昀昀erences between tes琀椀ng and debugging.

Tes琀椀ng Debugging
Tes琀椀ng starts with known condi琀椀ons, Debugging starts from possibly unknown
uses prede昀椀ned procedures and has ini琀椀al condi琀椀ons and the end cannot be
predictable outcomes. predicted except sta琀椀s琀椀cally.
Tes琀椀ng can and should be planned, Procedure and dura琀椀on of debugging cannot
designed and scheduled. be so constrained.
Tes琀椀ng is a demonstra琀椀on of error or
Debugging is a deduc琀椀ve process.
apparent correctness.
Debugging is the programmer's vindica琀椀on
Tes琀椀ng proves a programmer's failure.
(Jus琀椀昀椀ca琀椀on).
Tes琀椀ng, as executes, should strive to be
Debugging demands intui琀椀ve leaps,
predictable, dull, constrained, rigid and
experimenta琀椀on and freedom.
inhuman.
Much tes琀椀ng can be done without Debugging is impossible without detailed
design knowledge. design knowledge.
Tes琀椀ng can o昀琀en be done by an
Debugging must be done by an insider.
outsider.
Much of test execu琀椀on and design can
Automated debugging is s琀椀ll a dream.
be automated.

 Function versus Structure:

o Tests can be designed from a func琀椀onal or a structural point of view.


o In Func琀椀onal tes琀椀ng, the program or system is treated as a black box. It is
subjected to inputs, and its outputs are veri昀椀ed for conformance to speci昀椀ed
behavior. Func琀椀onal tes琀椀ng takes the user point of view- bother about

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

func琀椀onality and features and not the program's implementa琀椀on.


o In Structural tes琀椀ng does look at the implementa琀椀on details. Things such as
programming style, control method, source language, database design, and
coding details dominate structural tes琀椀ng.
o Both Structural and func琀椀onal tests are useful, both have limita琀椀ons, and both
target di昀昀erent kinds of bugs. Func琀椀onal tests can detect all bugs but would take
in昀椀nite 琀椀me to do so. Structural tests are inherently 昀椀nite but cannot detect all
errors even if completely executed.

 Designer versus Tester:

o Test designer is the person who designs the tests where as the tester is the one
actually tests the code. During func琀椀onal tes琀椀ng, the designer and tester are
probably di昀昀erent persons. During unit tes琀椀ng, the tester and the programmer
merge into one person.
o Tests designed and executed by the so昀琀ware designers are by nature biased
towards structural considera琀椀on and therefore su昀昀er the limita琀椀ons of
structural tes琀椀ng.

 Modularity versus Efficiency:

A module is a discrete, well-de昀椀ned, small component of a system. Smaller the modules, di昀케cult to
integrate; larger the modules, di昀케cult to understand. Both tests and systems can be modular. Tes琀椀ng can
and should likewise be organized into modular components. Small, independent test cases can be
designed to test independent modules.

 Small versus Large:

Programming in large means construc琀椀ng programs that consists of many components wri琀琀en by many
di昀昀erent programmers. Programming in the small is what we do for ourselves in the privacy of our own
o昀케ces. Qualita琀椀ve and Quan琀椀ta琀椀ve changes occur with size and so must tes琀椀ng methods and quality
criteria.

 Builder versus Buyer:

Most so昀琀ware is wri琀琀en and used by the same organiza琀椀on. Unfortunately, this situa琀椀on is dishonest
because it clouds accountability. If there is no separa琀椀on between builder and buyer, there can be no
accountability.
 The di昀昀erent roles / users in a system include:
1. Builder: Who designs the system and is accountable to the buyer.
2. Buyer: Who pays for the system in the hope of pro昀椀ts from providing services?
3. User: Ul琀椀mate bene昀椀ciary or vic琀椀m of the system. The user's interests are also
guarded by.
4. Tester: Who is dedicated to the builder's destruc琀椀on?
5. Operator: Who has to live with the builders' mistakes, the buyers' murky
(unclear) speci昀椀ca琀椀ons, testers' oversights and the users' complaints?

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

MODEL FOR TESTING:

Figure 1.1: A Model for Tes琀椀ng


Above 昀椀gure is a model of tes琀椀ng process. It includes three models: A model of the environment, a model of the
program and a model of the expected bugs.
 Environment:
o A Program's environment is the hardware and so昀琀ware required to make it run.
For online systems, the environment may include communica琀椀on lines, other
systems, terminals and operators.
o The environment also includes all programs that interact with and are used to
create the program under test - such as OS, linkage editor, loader, compiler,
u琀椀lity rou琀椀nes.
o Because the hardware and 昀椀rmware are stable, it is not smart to blame the
environment for bugs.
 Program:
o Most programs are too complicated to understand in detail.
o The concept of the program is to be simpli昀椀ed in order to test it.
o If simple model of the program doesn’t explain the unexpected behavior, we
may have to modify that model to include more facts and details. And if that
fails, we may have to modify the program.
 Bugs:
o Bugs are more insidious (deceiving but harmful) than ever we expect them to be.
o An unexpected test result may lead us to change our no琀椀on of what a bug is
and our model of bugs.
o Some op琀椀mis琀椀c no琀椀ons that many programmers or testers have about bugs are
usually unable to test e昀昀ec琀椀vely and unable to jus琀椀fy the dirty tests most
programs need.
o Optimistic notions about bugs:
1. Benign Bug Hypothesis: The belief that bugs are nice, tame and logical.

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

(Benign: Not Dangerous)

2. Bug Locality Hypothesis: The belief that a bug discovered with in a component a昀昀ects
only that component's behavior.
3. Control Bug Dominance: The belief those errors in the control structures (if, switch etc) of
programs dominate the bugs.
4. Code / Data Separa琀椀on: The belief that bugs respect the separa琀椀on of code and data.
5. Lingua Salvatore Est.: The belief that the language syntax and seman琀椀cs (e.g. Structured
Coding, Strong typing, etc) eliminates most bugs.
6. Correc琀椀ons Abide: The mistaken belief that a corrected bug remains corrected.
7. Silver Bullets: The mistaken belief that X (Language, Design method, representa琀椀on,
environment) grants immunity from bugs.
8. Sadism Su昀케ces: The common belief (especially by independent tester) that a sadis琀椀c
streak, low cunning, and intui琀椀on are su昀케cient to eliminate most bugs. Tough bugs need
methodology and techniques.
9. Angelic Testers: The belief that testers are be琀琀er at test design than programmers is at
code design.

 Test
s:
o Tests are formal procedures, Inputs must be prepared, Outcomes should predict,
tests should be documented, commands need to be executed, and results are to
be observed. All these errors are subjected to error
o We do three distinct kinds of testing on a typical software system.
They are:
1. Unit / Component Tes琀椀ng: A Unit is the smallest testable piece of
so昀琀ware that can be compiled, assembled, linked, loaded etc. A unit is
usually the work of one programmer and consists of several hundred or
fewer lines of code. Unit Tes琀椀ng is the tes琀椀ng we do to show that the
unit does not sa琀椀sfy its func琀椀onal speci昀椀ca琀椀on or that its implementa琀椀on
structure does not match the intended design structure. A Component is
an integrated aggregate of one or more units. Component Tes琀椀ng is the
tes琀椀ng we do to show that the component does not sa琀椀sfy its func琀椀onal
speci昀椀ca琀椀on or that its implementa琀椀on structure does not match the
intended design structure.
2. Integra琀椀on Tes琀椀ng: Integra琀椀on is the process by which components are
aggregated to create larger components. Integra琀椀on Tes琀椀ng is tes琀椀ng
done to show that even though the components were individually
sa琀椀sfactory (a昀琀er passing component tes琀椀ng), checks the combina琀椀on of
components are incorrect or inconsistent.

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

3. System Tes琀椀ng: A System is a big component. System Tes琀椀ng is aimed at


revealing bugs that cannot be a琀琀ributed to components. It includes
tes琀椀ng for performance, security, accountability, con昀椀gura琀椀on
sensi琀椀vity, startup and recovery.

 Role of Models: The art of tes琀椀ng consists of crea琀椀ng, selec琀椀ng, exploring, and revising
models. Our ability to go through this process depends on the number of di昀昀erent
models we have at hand and their ability to express a program's behavior.

CONSEQUENCES OF BUGS:

 Importance of bugs: The importance of bugs depends on frequency, correc琀椀on cost,


installa琀椀on cost, and consequences.
1. Frequency: How o昀琀en does that kind of bug occur? Pay more a琀琀en琀椀on to the
more frequent bug types.
2. Correc琀椀on Cost: What does it cost to correct the bug a昀琀er it is found? The cost is
the sum of 2 factors: (1) the cost of discovery (2) the cost of correc琀椀on. These
costs go up drama琀椀cally later in the development cycle when the bug is
discovered. Correc琀椀on cost also depends on system size.
3. Installa琀椀on Cost: Installa琀椀on cost depends on the number of installa琀椀ons: small
for a single user program but more for distributed systems. Fixing one bug and
distribu琀椀ng the 昀椀x could exceed the en琀椀re system's development cost.
4. Consequences: What are the consequences of the bug? Bug consequences can
range from mild to catastrophic.

A reasonable metric for bug importance is

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Importance= ($) = Frequency * (Correction cost + Installation cost +


Consequential cost)

 Consequences of bugs: The consequences of a bug can be measure in terms of


human rather than machine. Some consequences of a bug on a scale of one to ten
are:
1 Mild: The symptoms of the bug o昀昀end us aesthe琀椀cally (gently); a misspelled
output or a misaligned printout.
2 Moderate: Outputs are misleading or redundant. The bug impacts the system's
performance.
3 Annoying: The system's behavior because of the bug is dehumanizing. E.g.
Names are truncated or arbitrarily modi昀椀ed.
4 Disturbing: It refuses to handle legi琀椀mate (authorized / legal) transac琀椀ons. The
ATM won’t give you money. My credit card is declared invalid.
5 Serious: It loses track of its transac琀椀ons. Not just the transac琀椀on itself but the
fact that the transac琀椀on occurred. Accountability is lost.
6 Very Serious: The bug causes the system to do the wrong transac琀椀ons. Instead
of losing your paycheck, the system credits it to another account or converts
deposits to withdrawals.
7 Extreme: The problems aren't limited to a few users or to few transac琀椀on types.
They are frequent and arbitrary instead of sporadic infrequent) or for unusual
cases.
8 Intolerable: Long term unrecoverable corrup琀椀on of the database occurs and the
corrup琀椀on is not easily discovered. Serious considera琀椀on is given to shu琀�ng the
system down.
9 Catastrophic: The decision to shut down is taken out of our hands because the
system fails.
10 Infec琀椀ous: What can be worse than a failed system? One that corrupt other
systems even though it does not fall in itself ; that erodes the social physical
environment; that melts nuclear reactors and starts war.

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 Flexible severity rather than absolutes:

o Quality can be measured as a combina琀椀on of factors, of which number of bugs


and their severity is only one component.
o Many organiza琀椀ons have designed and used sa琀椀sfactory, quan琀椀ta琀椀ve, quality
metrics.
o Because bugs and their symptoms play a signi昀椀cant role in such metrics, as
tes琀椀ng progresses, you see the quality rise to a reasonable value which is
deemed to be safe to ship the product.
o The factors involved in bug severity are:
1. Correc琀椀on Cost: Not so important because catastrophic bugs may be
corrected easier and small bugs may take major 琀椀me to debug.
2. Context and Applica琀椀on Dependency: Severity depends on the context
and the applica琀椀on in which it isused.
3. Crea琀椀ng Culture Dependency: What’s important depends on the
creators of so昀琀ware and their cultural aspira琀椀ons. Test tool vendors are
more sensi琀椀ve about bugs in their so昀琀ware then games so昀琀ware
vendors.
4. User Culture Dependency: Severity also depends on user culture. Naive
users of PC so昀琀ware go crazy over bugs where as pros (experts) may just
ignore.
5. The so昀琀ware development phase: Severity depends on development
phase. Any bugs gets more severe as it gets closer to 昀椀eld use and more
severe the longer it has been around.

TAXONOMY OF BUGS:
 There is no universally correct way categorize bugs. The taxonomy is not rigid.
 A given bug can be put into one or another category depending on its history and the
programmer's state of mind.
 The major categories are: (1) Requirements, Features and Func琀椀onality Bugs (2)
Structural Bugs (3) Data Bugs (4) Coding Bugs (5) Interface, Integra琀椀on and System
Bugs (6) Test and Test Design Bugs.

 Requirements, Features and Func琀椀onality Bugs: Various categories in Requirements,


Features and Func琀椀onality bugs include:

1. Requirements and Specifications Bugs:


 Requirements and speci昀椀ca琀椀ons developed from them can be incomplete ambiguous,
or self-contradictory. They can be misunderstood or impossible to understand.
 The speci昀椀ca琀椀ons that don't have 昀氀aws in them may change while the design is
in progress. The features are added, modi昀椀ed and deleted.
 Requirements, especially, as expressed in speci昀椀ca琀椀ons are a major source of expensive
bugs.
 The range is from a few percentages to more than 50%, depending on the applica琀椀on

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

and environment.
 What hurts most about the bugs is that they are the earliest to invade the system
and the last to leave.
2. Feature Bugs:
 Speci昀椀ca琀椀on problems usually create corresponding feature problems.
 A feature can be wrong, missing, or super昀氀uous (serving no useful purpose). A missing
feature or case is easier to detect and correct. A wrong feature could have deep design
implica琀椀ons.
 Removing the features might complicate the so昀琀ware, consume more resources, and
foster more bugs.

3. Feature Interaction Bugs:


 Providing correct, clear, implementable and testable feature speci昀椀ca琀椀ons is not enough.
 Features usually come in groups or related features. The features of each group and the
interac琀椀on of features within the group are usually well tested.
 The problem is unpredictable interac琀椀ons between feature groups or even between
individual features. For example, your telephone is provided with call holding and call
forwarding. The interac琀椀ons between these two features may have bugs.
 Every applica琀椀on has its peculiar set of features and a much bigger set of unspeci昀椀ed
feature interac琀椀on poten琀椀als and therefore result in feature interac琀椀on bugs.

Specification and Feature Bug Remedies:


 Most feature bugs are rooted in human to human communica琀椀on problems. One
solu琀椀on is to use high-level, formal speci昀椀ca琀椀on languages or systems.
 Such languages and systems provide short term support but in the long run, does not
solve the problem.
 Short term Support: Speci昀椀ca琀椀on languages facilitate formaliza琀椀on of requirements
and inconsistency and ambiguity analysis.
 Long term Support: Assume that we have a great speci昀椀ca琀椀on language and that can be
used to create unambiguous, complete speci昀椀ca琀椀ons with unambiguous complete tests
and consistent test criteria.
 The speci昀椀ca琀椀on problem has been shi昀琀ed to a higher level but not eliminated.
Tes琀椀ng Techniques for func琀椀onal bugs: Most func琀椀onal test techniques- that is those techniques which are based on
a behavioral descrip琀椀on of so昀琀ware, such as transac琀椀on 昀氀ow tes琀椀ng, syntax tes琀椀ng, domain tes琀椀ng, logic tes琀椀ng and
state tes琀椀ng are useful in tes琀椀ng func琀椀onal bugs.

 Structural bugs: Various categories in Structural bugs include:


1. Control and Sequence Bugs:
 Control and sequence bugs include paths le昀琀 out, unreachable code, improper nes琀椀ng
of loops, loop-back or loop termina琀椀on criteria incorrect, missing process steps,
duplicated processing, unnecessary processing, rampaging, GOTO's, ill-conceived (not
properly planned) switches, spaghe琀� code, and worst of all, pachinko code.
 One reason for control 昀氀ow bugs is that this area is amenable (suppor琀椀ve) to theore琀椀cal
treatment.
 Most of the control 昀氀ow bugs are easily tested and caught in unit tes琀椀ng.

10

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 Another reason for control 昀氀ow bugs is that use of old code especially ALP & COBOL
code are dominated by control 昀氀ow bugs.
 Control and sequence bugs at all levels are caught by tes琀椀ng, especially structural
tes琀椀ng, more speci昀椀cally path tes琀椀ng combined with a bo琀琀om line func琀椀onal test based
on a speci昀椀ca琀椀on.

2. Logic Bugs:
 Bugs in logic, especially those related to misunderstanding how case statements and
logic operators behave singly and combina琀椀ons
 Also includes evalua琀椀on of boolean expressions in deeply nested IF-THEN-ELSE
constructs.
 If the bugs are parts of logical (i.e. boolean) processing not related to control 昀氀ow, they
are characterized as processing bugs.
 If the bugs are parts of a logical expression (i.e. control-昀氀ow statement) which is used to
direct the control 昀氀ow, then they are categorized as control-昀氀ow bugs.

3. Processing Bugs:
 Processing bugs include arithme琀椀c bugs, algebraic, mathema琀椀cal func琀椀on evalua琀椀on,
algorithm selec琀椀on and general processing.
 Examples of Processing bugs include: Incorrect conversion from one data
representa琀椀on to other, ignoring over昀氀ow, improper use of greater-than-or-equal etc
 Although these bugs are frequent (12%), they tend to be caught in good unit tes琀椀ng.

4. Initialization Bugs:
 Ini琀椀aliza琀椀on bugs are common. Ini琀椀aliza琀椀on bugs can be improper and super昀氀uous.
 Super昀氀uous bugs are generally less harmful but can a昀昀ect performance.
 Typical ini琀椀aliza琀椀on bugs include: Forge琀�ng to ini琀椀alize the variables before 昀椀rst use,
assuming that they are ini琀椀alized elsewhere, ini琀椀alizing to the wrong format,
representa琀椀on or type etc
 Explicit declara琀椀on of all variables, as in Pascal, can reduce some ini琀椀aliza琀椀on problems.

5. Data-Flow Bugs and Anomalies:


 Most ini琀椀aliza琀椀on bugs are special case of data 昀氀ow anomalies.
 A data 昀氀ow anomaly occurs where there is a path along which we expect to do
something unreasonable with data, such as using an unini琀椀alized variable, a琀琀emp琀椀ng to
use a variable before it exists, modifying and then not storing or using the result, or
ini琀椀alizing twice without an intermediate use.

 Data bugs:
 Data bugs include all bugs that arise from the speci昀椀ca琀椀on of data objects, their
formats, the number of such objects, and their ini琀椀al values.
 Data Bugs are at least as common as bugs in code, but they are o昀琀en treated as if they
did not exist at all.
 Code migrates data: So昀琀ware is evolving towards programs in which more and more of

11

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

the control and processing func琀椀ons are stored in tables.


 Because of this, there is an increasing awareness that bugs in code are only half the
ba琀琀le and the data problems should be given equal a琀琀en琀椀on.

Dynamic Data Vs Static data:

 Dynamic data are transitory. Whatever their purpose their life琀椀me is rela琀椀vely short,
typically the processing 琀椀me of one transac琀椀on. A storage object may be used to hold
dynamic data of di昀昀erent types, with di昀昀erent formats, a琀琀ributes and residues.
 Dynamic data bugs are due to le昀琀over garbage in a shared resource. This can be
handled in one of the three ways: (1) Clean up a昀琀er the use by the user (2) Common
Cleanup by the resource manager (3) No Clean up
 Sta琀椀c Data are 昀椀xed in form and content. They appear in the source code or database
directly or indirectly, for example a number, a string of characters, or a bit pa琀琀ern.
 Compile 琀椀me processing will solve the bugs caused by sta琀椀c data.

Information, parameter, and control:


Sta琀椀c or dynamic data can serve in one of three roles, or in combina琀椀on of roles: as a parameter, for control, or for
informa琀椀on.

Content, Structure and Attributes:


 Content can be an actual bit pa琀琀ern, character string, or number put into a data
structure. Content is a pure bit pa琀琀ern and has no meaning unless it is interpreted by a
hardware or so昀琀ware processor. All data bugs result in the corrup琀椀on or
misinterpreta琀椀on of content.
 Structure relates to the size, shape and numbers that describe the data object, which is
memory loca琀椀on used to store the content. (E.g. A two dimensional array).
 A琀琀ributes relates to the speci昀椀ca琀椀on meaning that is the seman琀椀cs associated with the
contents of a data object. (E.g. an integer, an alphanumeric string, a subrou琀椀ne). The
severity and subtlety of bugs increases as we go from content to a琀琀ributes because the
things get less formal in that direc琀椀on.

 Coding bugs:
 Coding errors of all kinds can create any of the other kind of bugs.
 Syntax errors are generally not important in the scheme of things if the source language
translator has adequate syntax checking.
 If a program has many syntax errors, then we should expect many logic and coding bugs.
 The documenta琀椀on bugs are also considered as coding bugs which may mislead the
maintenance programmers.

 Interface, integration, and system bugs:


Various categories of bugs in Interface, Integra琀椀on, and System Bugs are:

1. External Interfaces:

12

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 The external interfaces are the means used to communicate with the world.
 These include devices, actuators, sensors, input terminals, printers, and communica琀椀on
lines.
 The primary design criterion for an interface with outside world should be robustness.
 All external interfaces, human or machine should employ a protocol. The protocol may
be wrong or incorrectly implemented.
 Other external interface bugs are: invalid 琀椀ming or sequence assump琀椀ons related to
external signals
 Misunderstanding external input or output formats.
 Insu昀케cient tolerance to bad input data.

2.Internal Interfaces:
 Internal interfaces are in principle not di昀昀erent from external interfaces but they are
more controlled.
 A best example for internal interfaces is communica琀椀ng rou琀椀nes.
 The external environment is 昀椀xed and the system must adapt to it but the internal
environment, which consists of interfaces with other components, can be nego琀椀ated.
 Internal interfaces have the same problem as external interfaces.

3. Hardware Architecture:
 Bugs related to hardware architecture originate mostly from misunderstanding how the
hardware works.
 Examples of hardware architecture bugs: address genera琀椀on error, i/o device opera琀椀on
/ instruc琀椀on error, wai琀椀ng too long for a response, incorrect interrupt handling etc.
 The remedy for hardware architecture and interface problems is twofold: (1) Good
Programming and Tes琀椀ng (2) Centraliza琀椀on of hardware interface so昀琀ware in programs
wri琀琀en by hardware interface specialists.

4. Operating System Bugs:


 Program bugs related to the opera琀椀ng system are a combina琀椀on of hardware
architecture and interface bugs mostly caused by a misunderstanding of what it is the
opera琀椀ng system does.
 Use opera琀椀ng system interface specialists, and use explicit interface modules or macros
for all opera琀椀ng system calls.
 This approach may not eliminate the bugs but at least will localize them and
make tes琀椀ng easier.

5. Software Architecture:
 So昀琀ware architecture bugs are the kind that called - interac琀椀ve.
 Rou琀椀nes can pass unit and integra琀椀on tes琀椀ng without revealing such bugs.
 Many of them depend on load, and their symptoms emerge only when the system is
stressed.
 Sample for such bugs: Assump琀椀on that there will be no interrupts, Failure to block or un
block interrupts, Assump琀椀on that memory and registers were ini琀椀alized or not

13

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

ini琀椀alized etc
 Careful integra琀椀on of modules and subjec琀椀ng the 昀椀nal system toa stress test are
e昀昀ec琀椀ve methods for these bugs.
6. Control and Sequence Bugs (Systems Level):
These bugs include: Ignored 琀椀ming, Assuming that events occur in a speci昀椀ed sequence, Working on data
before all the data have arrived from disc, Wai琀椀ng for an impossible combina琀椀on of prerequisites, Missing,
wrong, redundant or super昀氀uous process steps.
The remedy for these bugs is highly structured sequence control.
Specialize, internal, sequence control mechanisms are helpful.

7. Resource Management Problems:


 Memory is subdivided into dynamically allocated resources such as bu昀昀er blocks, queue
blocks, task control blocks, and overlay bu昀昀ers.
 External mass storage units such as discs, are subdivided into memory resource pools.
 Some resource management and usage bugs: Required resource not obtained, Wrong
resource used, Resource is already in use, Resource dead lock etc
 Resource Management Remedies: A design remedy that prevents bugs is always
preferable to a test method that discovers them.
 The design remedy in resource management is to keep the resource structure simple:
the fewest di昀昀erent kinds of resources, the fewest pools, and no private resource
management.

8. Integration Bugs:
 Integra琀椀on bugs are bugs having to do with the integra琀椀on of, and with the interfaces
between, working and tested components.
 These bugs results from inconsistencies or incompa琀椀bili琀椀es between components.
 The communica琀椀on methods include data structures, call sequences, registers,
semaphores, and communica琀椀on links and protocols results in integra琀椀on bugs.
 The integra琀椀on bugs do not cons琀椀tute a big bug category (9%) they are expensive
category because they are usually caught late in the game and because they force
changes in several components and/or data structures.

9. System Bugs:
 System bugs covering all kinds of bugs that cannot be ascribed to a component or to
their simple interac琀椀ons, but result from the totality of interac琀椀ons between many
components such as programs, data, hardware, and the opera琀椀ng systems.
 There can be no meaningful system tes琀椀ng un琀椀l there has been thorough component
and integra琀椀on tes琀椀ng.
 System bugs are infrequent (1.7%) but very important because they are o昀琀en found
only a昀琀er the system has been 昀椀elded.

 TEST AND TEST DESIGN BUGS:


 Tes琀椀ng: testers have no immunity to bugs. Tests require complicated scenarios and
databases.
 They require code or the equivalent to execute and consequently they can have bugs.

14

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 Test criteria: if the speci昀椀ca琀椀on is correct, it is correctly interpreted and implemented,


and a proper test has been designed; but the criterion by which the so昀琀ware's behavior
is
judged may be incorrect or impossible. So, a proper test criteria has to be designed. The more
complicated the criteria, the likelier they are to have bugs.

Remedies: The remedies of test bugs are:


1. Test Debugging: The 昀椀rst remedy for test bugs is tes琀椀ng and debugging the tests. Test
debugging, when compared to program debugging, is easier because tests, when properly
designed are simpler than programs and do not have to make concessions to e昀케ciency.
2. Test Quality Assurance: Programmers have the right to ask how quality in independent
tes琀椀ng is monitored.
3. Test Execu琀椀on Automa琀椀on: The history of so昀琀ware bug removal and preven琀椀on is
indis琀椀nguishable from the history of programming automa琀椀on aids. Assemblers, loaders,
compilers are developed to reduce the incidence of programming and opera琀椀on errors. Test
execu琀椀on bugs are virtually eliminated by various test execu琀椀on automa琀椀on tools.
4. Test Design Automa琀椀on: Just as much of so昀琀ware development has been automated, much
test design can be and has been automated. For a given produc琀椀vity rate, automa琀椀on reduces
the bug count - be it for so昀琀ware or be it for tests.
\\\

FLOW GRAPHS AND PATH TESTING

BASICS OF PATH TESTING:

 Path Tes琀椀ng:
o Path Tes琀椀ng is the name given to a family of test techniques based
on judiciously selec琀椀ng a set of test paths through the program.
o If the set of paths are properly chosen then we have achieved some measure
of test thoroughness. For example, pick enough paths to assure that every
source statement has been executed at least once.
o Path tes琀椀ng techniques are the oldest of all structural test techniques.
o Path tes琀椀ng is most applicable to new so昀琀ware for unit tes琀椀ng. It is
a structural technique.
o It requires complete knowledge of the program's structure.
o It is most o昀琀en used by programmers to unit test their own code.
o The e昀昀ec琀椀veness of path tes琀椀ng rapidly deteriorates as the size of the
so昀琀ware aggregate under test increases.

 The Bug Assumption:


o The bug assump琀椀on for the path tes琀椀ng strategies is that something has
gone wrong with the so昀琀ware that makes it take a di昀昀erent path than
intended.
o As an example "GOTO X" where "GOTO Y" had been intended.
15

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

o Structured programming languages prevent many of the bugs targeted by path


tes琀椀ng: as a consequence the e昀昀ec琀椀veness for path tes琀椀ng for these languages
is reduced and for old code in COBOL, ALP, FORTRAN and Basic, the path
tes琀椀ng is indispensable.

 Control Flow Graphs:


o The control 昀氀ow graph is a graphical representa琀椀on of a program's
control structure. It uses the elements named process blocks, decisions,
and junc琀椀ons.
o The 昀氀ow graph is similar to the earlier 昀氀owchart, with which it is not to be confused.

o Flow Graph Elements: A 昀氀ow graph contains four di昀昀erent types of elements.
(1) Process Block (2) Decisions (3) Junc琀椀ons (4) Case Statements
1. Process Block:
 A process block is a sequence of program
statements uninterrupted by either decisions or
junc琀椀ons.
 It is a sequence of statements such that if any one of
statement of the block is executed, then all statement thereof
are executed.
 Formally, a process block is a piece of straight line code of
one statement or hundreds of statements.
 A process has one entry and one exit. It can consists of a single
statement or instruc琀椀on, a sequence of statements or
instruc琀椀ons, a
single entry/exit subrou琀椀ne, a macro or func琀椀on call, or a sequence of these.

2. Decisions:
 A decision is a program point at which the control
昀氀ow can diverge.
 Machine language condi琀椀onal branch and condi琀椀onal
skip instruc琀椀ons are examples of decisions.
 Most of the decisions are two-way but some are
three way branches in control 昀氀ow.
3. Case Statements:
 A case statement is a mul琀椀-way branch or decisions.
 Examples of case statement are a jump table in
assembly language, and the PASCAL case statement.
 From the point of view of test design, there are no
di昀昀erences between Decisions and Case Statements
4. Junctions:
 A junc琀椀on is a point in the program where the control
昀氀ow can merge.
 Examples of junc琀椀ons are: the target of a jump or

16

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

skip instruc琀椀on in ALP, a label that is a target of


GOTO.

17

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 2.1: Flow graph Elements


Control Flow Graphs Vs Flowcharts:
o A program's 昀氀ow chart resembles a control 昀氀ow graph.
o In 昀氀ow graphs, we don't show the details of what is in a process block.
o In 昀氀ow charts every part of the process block is drawn.
o The 昀氀owchart focuses on process steps, where as the 昀氀ow graph focuses on
control 昀氀ow of the program.
o The act of drawing a control 昀氀ow graph is a useful tool that can help us clarify the
control 昀氀ow and data 昀氀ow issues.

Notational Evolution:
The control 昀氀ow graph is simpli昀椀ed representa琀椀on of the program's structure.The nota琀椀on changes made in
crea琀椀on of control 昀氀ow graphs:
o The process boxes weren't really needed. There is an implied process on every line
joining junc琀椀ons and decisions.
o We don't need to know the speci昀椀cs of the decisions, just the fact that there is a branch.
o The speci昀椀c target label names aren't important-just the fact that they exist. So we can
replace them by simple numbers.
o To understand this, we will go through an example (Figure 2.2) wri琀琀en in a FORTRAN
like programming language called Programming Design Language (PDL). The program's
corresponding 昀氀owchart (Figure 2.3) and 昀氀owgraph (Figure 2.4) were also provided
below for be琀琀er understanding.
o The 昀椀rst step in transla琀椀ng the program to a 昀氀owchart is shown in Figure 2.3, where we
have the typical one-for-one classical 昀氀owchart. Note that complexity has increased,
18

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

clarity has decreased, and that we had to add auxiliary labels (LOOP, XX, and YY), which
have no actual program counterpart. In Figure 2.4 we merged the process steps and
replaced them with the single process box.

o We now have a control 昀氀ow graph. But this representa琀椀on is s琀椀ll too busy. We simplify
the nota琀椀on further to achieve Figure 2.5, where for the 昀椀rst 琀椀me we can really see
what the control 昀氀ow looks like.

Figure 2.2: Program Example (PDL)

Figure 2.3: One-to-one 昀氀owchart for example program in Figure 2.2


19

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 2.4: Control Flow graph for example in Figure 2.2

Figure 2.5: Simpli昀椀ed Flow graph Nota琀椀on

Figure 2.6: Even Simpli昀椀ed Flow graph Nota琀椀on


The 昀椀nal transforma琀椀on is shown in Figure 2.6, where we've dropped the node numbers to achieve an even
simpler representa琀椀on. The way to work with control 昀氀ow graphs is to use the simplest possible representa琀椀on -
that is, no more informa琀椀on than you need to correlate back to the source program or PDL.

LINKED LIST REPRESENTATION:

Although graphical representa琀椀ons of 昀氀ow graphs are revealing, the details of the control 昀氀ow inside a program

20

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

they are o昀琀en inconvenient.


In linked list representa琀椀on, each node has a name and there is an entry on the list for each link

in the 昀氀ow graph. Only the informa琀椀on per琀椀nent to the control 昀氀ow is shown.
Linked List representation of Flow Graph:

Figure 2.7: Linked List Control Flow graph Nota琀椀on

FLOWGRAPH - PROGRAM CORRESPONDENCE:


A 昀氀ow graph is a pictorial representa琀椀on of a program and not the program itself, just as a topographic map.
You can’t always associate the parts of a program in a unique way with 昀氀ow graph parts because many program
structures, such as if-then-else constructs, consists of a combina琀椀on of decisions, junc琀椀ons, and processes.
The transla琀椀on from a 昀氀ow graph element to a statement and vice versa is not always unique. (See Figure 2.8)

21

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 2.8: Alternative Flow graphs for


same logic (Statement "IF (A=0) AND
(B=1) THEN . . .").
An improper transla琀椀on from 昀氀ow graph to code during coding can lead to bugs, and improper transla琀椀on during the test
design lead to missing test cases and causes undiscovered bugs.

FLOWGRAPH AND FLOWCHART GENERATION:

Flowcharts can be
1. Handwri琀琀en by the programmer.
2. Automa琀椀cally produced by a 昀氀owchar琀椀ng program based on a mechanical analysis
of the source code.
3. Semi automa琀椀cally produced by a 昀氀ow char琀椀ng program based in part on
structural analysis of the source code and in part on direc琀椀ons given by
the programmer.
There are rela琀椀vely few control 昀氀ow graph generators.

PATH TESTING - PATHS, NODES AND LINKS:

Path: A path through a program is a sequence of instruc琀椀ons or statements that starts at an entry,
junc琀椀on, or decision and ends at another, or possibly the same junc琀椀on, decision, or exit.
o A path may go through several junc琀椀ons, processes, or decisions, one
or more 琀椀mes.
o Paths consist of segments.
o The segment is a link - a single process that lies between two nodes.
o A path segment is succession of consecu琀椀ve links that belongs to some path.
o The length of path measured by the number of links in it and not by the
number of the instruc琀椀ons or statements executed along that path.
o The name of a path is the name of the nodes along the path.

FUNDAMENTAL PATH SELECTION CRITERIA:

There are many paths between the entry and exit of a typical rou琀椀ne.
Every decision doubles the number of poten琀椀al paths. And every loop mul琀椀plies the number of poten琀椀al paths by the
number of di昀昀erent itera琀椀on values possible for the loop.
De昀椀ning complete tes琀椀ng:
1. Exercise every path from entry to exit.
2. Exercise every statement or instruc琀椀on at least once.
3. Exercise every branch and case statement, in each direc琀椀on at least once.
If prescrip琀椀on 1 is followed then 2 and 3 are automa琀椀cally followed. But it is imprac琀椀cal for most rou琀椀nes. It
can be done for the rou琀椀nes that have no loops, in which it is equivalent to 2 and 3 prescrip琀椀ons.

22

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

EXAMPLE: Here is the correct version.

For X nega琀椀ve, the output is X + A, while for X greater than or equal to zero, the output is X + 2A. Following
prescrip琀椀on 2 and execu琀椀ng every statement, but not every branch, would not reveal the bug in the following
incorrect version:

A nega琀椀ve value produces the correct answer. Every statement can be executed, but if the test cases do not force
each branch to be taken, the bug can remain hidden. The next example uses a test based on execu琀椀ng each branch
but does not force the execu琀椀on of all statements:

The hidden loop around label 100 is not revealed by tests based on prescrip琀椀on 3 alone because no test forces the
execu琀椀on of statement 100 and the following GOTO statement. Furthermore, label 100 is not 昀氀agged by the
compiler as an unreferenced label and the subsequent GOTO does not refer to an unde昀椀ned label.

A Sta琀椀c Analysis (that is, an analysis based on examining the source code or structure) cannot determine whether
a piece of code is or is not reachable. There could be subrou琀椀ne calls with parameters that are subrou琀椀ne labels,
or in the above example there could be a GOTO that targeted label 100 but could never achieve a value that would
send the program to that label.

Only a Dynamic Analysis (that is, an analysis based on the code's behavior while running - which is to say, to all
intents and purposes, tes琀椀ng) can determine whether code is reachable or not and therefore dis琀椀nguish between
the ideal structure we think we have and the actual, buggy structure.

PATH TESTING CRITERIA:

Any tes琀椀ng strategy based on paths must at least both exercise every instruc琀椀on and take branches in all
direc琀椀ons.
A set of tests that does this is not complete in an absolute sense, but it is complete in the sense that anything less
23

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

must leave something untested.


So we have explored three di昀昀erent tes琀椀ng criteria or strategies out of a poten琀椀ally in昀椀nite family of strategies.

i. Path Testing (Pinf):


1. Execute all possible control 昀氀ow paths through the program: typically, this is
restricted to all possible entry/exit paths through the program.
2. If we achieve this prescrip琀椀on, we are said to have achieved 100% path coverage.
This is the strongest criterion in the path tes琀椀ng strategy family: it is generally
impossible to achieve.
ii. Statement Testing (P1):
1. Execute all statements in the program at least once under some test. If we do
enough tests to achieve this, we are said to have achieved 100% statement
coverage.
2. An alternate equivalent characteriza琀椀on is to say that we have achieved 100% node
coverage. We denote this by C1.
3. This is the weakest criterion in the family: tes琀椀ng less than this for new so昀琀ware is
unconscionable (unprincipled or cannot be accepted) and should be criminalized.

iii. Branch Testing (P2):


1. Execute enough tests to assure that every branch alterna琀椀ve has been exercised at
least once under some test.
2. If we do enough tests to achieve this prescrip琀椀on, then we have achieved 100%
branch coverage.
3. An alterna琀椀ve characteriza琀椀on is to say that we have achieved 100% link coverage.
4. For structured so昀琀ware, branch tes琀椀ng and therefore branch coverage strictly includes
statement coverage.
5. We denote branch coverage by C2.

Commonsense and Strategies:


 Branch and statement coverage are accepted today as the minimum mandatory tes琀椀ng
requirement.
 The ques琀椀on "why not use a judicious sampling of paths?, what is wrong with leaving
some code, untested?" is ine昀昀ectual in the view of common sense and experience since:
(1.) Not tes琀椀ng a piece of a code leaves a residue of bugs in the program in propor琀椀on
to the size of the untested code and the probability of bugs. (2.) The high probability
paths are always thoroughly tested if only to demonstrate that the system works
properly.
 Which paths to be tested? You must pick enough paths to achieve C1+C2. The ques琀椀on
of what is the fewest number of such paths is interes琀椀ng to the designer of test tools
that help automate the path tes琀椀ng, but it is not crucial to the pragma琀椀c (prac琀椀cal)
design of tests. It is be琀琀er to make many simple paths than a few complicated paths.

24

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 Path Selection Example:

Figure 2.9: An example 昀氀ow graph to explain path selec琀椀on

Prac琀椀cal Sugges琀椀ons in Path Tes琀椀ng:

1. Draw the control 昀氀ow graph on a single sheet of paper.


2. Make several copies - as many as you will need for coverage (C1+C2) and several more.
3. Use a yellow highligh琀椀ng marker to trace paths. Copy the paths onto master sheets.
4. Con琀椀nue tracing paths un琀椀l all lines on the master sheet are covered, indica琀椀ng that
you appear to have achieved C1+C2.
5. As you trace the paths, create a table that shows the paths, the coverage status of
each process, and each decision.
6. The above paths lead to the following table considering Figure 2.9:

7. A昀琀er you have traced a covering path set on the master sheet and 昀椀lled in the
table for every path, check the following:
1. Does every decision have a YES and a NO in its column? (C2)
2. Has every case of all case statements been marked? (C2)
3. Is every three - way branch (less, equal, greater) covered? (C2)
25

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

4. Is every link (process) covered at least once? (C1)


8. Revised Path Selection Rules:
 Pick the simplest, func琀椀onally sensible entry/exit path.
 Pick addi琀椀onal paths as small varia琀椀on from previous paths. Pick paths that do not
have loops rather than paths that do. Favor short paths that make sense over paths
that don't.
 Pick addi琀椀onal paths that have no obvious func琀椀onal meaning only if it's necessary
to provide coverage.
 Be comfortable with your chosen paths. Play your hunches (guesses) and give your
intui琀椀on free reign as long as you achieve C1+C2.
 Don't follow rules slavishly (blindly) - except for coverage.

LOOPS:

Cases for a single loop: A Single loop can be covered with two cases: Looping and Not looping. But, experience
shows that many loop-related bugs are not discovered by C1+C2. Bugs hide themselves in corners and congregate at
boundaries - in the cases of loops, at or around the minimum or maximum number of 琀椀mes the loop can be
iterated. The minimum number of itera琀椀ons is o昀琀en zero, but it need not be.

CASE 1: Single loop, Zero minimum, N maximum, No excluded values


1. Try bypassing the loop (zero itera琀椀ons). If you can't, you either have a bug, or zero is
not the minimum and you have the wrong case.
2. Could the loop-control variable be nega琀椀ve? Could it appear to specify a nega琀椀ve
number of itera琀椀ons? What happens to such a value?
3. One pass through the loop.
4. Two passes through the loop.
5. A typical number of itera琀椀ons, unless covered by a previous test.
6. One less than the maximum number of itera琀椀ons.
7. The maximum number of itera琀椀ons.
8. A琀琀empt one more than the maximum number of itera琀椀ons. What prevents the loop-
control variable from having this value? What will happen with this value if it is
forced?

CASE 2: Single loop, Non-zero minimum, No excluded values


1. Try one less than the expected minimum. What happens if the loop control
variable's value is less than the minimum? What prevents the value from being less
than the minimum?
2. The minimum number of itera琀椀ons.
3. One more than the minimum number of itera琀椀ons.
4. Once, unless covered by a previous test.
5. Twice, unless covered by a previous test.
6. A typical value.
7. One less than the maximum value.

26

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

8. The maximum number of itera琀椀ons.

27

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

9. A琀琀empt one more than the maximum number of itera琀椀ons.


CASE 3: Single loops with excluded values
 Treat single loops with excluded values as two sets of tests consis琀椀ng of loops without
excluded values, such as case 1 and 2 above.
 Example, the total range of the loop control variable was 1 to 20, but that values 7, 8,9,10
were excluded. The two sets of tests are 1-6 and 11-20.
 The test cases to a琀琀empt would be 0,1,2,4,6,7 for the 昀椀rst range and
10,11,15,19,20,21 for the second range.

Kinds of Loops: There are only three kinds of loops with respect to path tes琀椀ng:

 Nested Loops:
The number of tests to be performed on nested loops will be the exponent of the tests performed on single
loops.As we cannot always a昀昀ord to test all combina琀椀ons of nested loops' itera琀椀ons values. Here's a tac琀椀c
used to discard some of these values:
1. Start at the inner most loop. Set all the outer loops to their minimum values.
2. Test the minimum, minimum+1, typical, maximum-1 , and maximum for the
innermost loop, while holding the outer loops at their minimum itera琀椀on parameter
values. Expand the tests as required for out of range and excluded values.
3. If you've done the outmost loop, GOTO step 5, else move out one loop and set it up as
in step 2 with all other loops set to typical values.
4. Con琀椀nue outward in this manner un琀椀l all loops have been covered.
5. Do all the cases for all loops in the nest simultaneously.

 Concatenated Loops:
Concatenated loops fall between single and nested loops with respect to test cases. Two loops are
concatenated if it's possible to reach one a昀琀er exi琀椀ng the other while s琀椀ll on a path from entrance to exit.
If the loops cannot be on the same path, then they are not concatenated and can be treated as individual
loops.

 Horrible Loops:
A horrible loop is a combina琀椀on of nested loops, the use of code that jumps into and out of loops,
intersec琀椀ng loops, hidden loops, and cross connected loops.
Makes itera琀椀on value selec琀椀on for test cases an awesome and ugly task, which is another reason such
structures should be avoided.

28

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 2.10: Example of Loop types

Loop Tes琀椀ng Time:


Any kind of loop can lead to long tes琀椀ng 琀椀me, especially if all the extreme value cases are to a琀琀empted
(Max-1, Max, Max+1).
 This situa琀椀on is obviously worse for nested and dependent concatenated loops.
 Consider nested loops in which tes琀椀ng the combina琀椀on of extreme values lead to
long test 琀椀mes. Several op琀椀ons to deal with:
 Prove that the combined extreme cases are hypothe琀椀cally possible, they are not possible
in the real world

29

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 Put in limits or checks that prevent the combined extreme cases. Then you have to test
the so昀琀ware that implements such safety measures.

PREDICATES, PATH PREDICATES AND ACHIEVABLE PATHS:

PREDICATE: The logical func琀椀on evaluated at a decision is called Predicate. The direc琀椀on taken at a decision
depends on the value of decision variable. Some examples are: A>0, x+y>=90.......

PATH PREDICATE: A predicate associated with a path is called a Path Predicate. For example, "x is greater than
zero", "x+y>=90", "w is either nega琀椀ve or equal to 10 is true" is a sequence of predicates whose truth values will
cause the rou琀椀ne to take a speci昀椀c path.

MULTIWAY BRANCHES:
The path taken through a mul琀椀way branch such as a computed GOTO's, case statement, or
jump tables cannot be directly expressed in TRUE/FALSE terms.
Although, it is possible to describe such alterna琀椀ves by using mul琀椀 valued logic, an
expedient (prac琀椀cal approach) is to express mul琀椀way branches as an equivalent set of
if..then..else statements.
For example a three way case statement can be wri琀琀en as: If case=1 DO A1 ELSE (IF Case=2
DO A2 ELSE DO A3 ENDIF)ENDIF.

INPUTS:
In tes琀椀ng, the word input is not restricted to direct inputs, such as variables in a subrou琀椀ne
call, but includes all data objects referenced by the rou琀椀ne whose values are 昀椀xed prior to
entering it.
For example, inputs in a calling sequence, objects in a data structure, values le昀琀 in
registers, or any combina琀椀on of object types.
The input for a par琀椀cular test is mapped as a one dimensional array called as an Input
Vector.

PREDICATE INTERPRETATION:
The simplest predicate depends only on input variables.
For example if x1,x2 are inputs, the predicate might be x1+x2>=7, given the values of x1
and x2 the direc琀椀on taken through the decision is based on the predicate is determined at
input 琀椀me and does not depend on processing.
Another example, assume a predicate x1+y>=0 that along a path prior to reaching this
predicate we had the assignment statement y=x2+7. although our predicate depends on
processing, we can subs琀椀tute the symbolic expression for y to obtain an equivalent
predicate x1+x2+7>=0.
The act of symbolic subs琀椀tu琀椀on of opera琀椀ons along the path in order to express the
predicate solely in terms of the input vector is called predicate interpreta琀椀on.
Some琀椀mes the interpreta琀椀on may depend on the path; for

30

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

example, INPUT X
ON X GOTO A, B, C, ...
A: Z := 7 @ GOTO HEM B: Z := -
7 @ GOTO HEM C: Z := 0 @
GOTO HEM
.........
HEM: DO SOMETHING
.........
HEN: IF Y + Z > 0 GOTO ELL ELSE GOTO EMM
The predicate interpreta琀椀on at HEN depends on the path we took through the 昀椀rst mul琀椀way branch. It yields for
the three cases respec琀椀vely, if Y+7>0, Y-7>0, Y>0.
The path predicates are the speci昀椀c form of the predicates of the decisions along the
selected path a昀琀er interpreta琀椀on.

INDEPENDENCE OF VARIABLES AND PREDICATES:


The path predicates take on truth values based on the values of input variables, either
directly or indirectly.
If a variable's value does not change as a result of processing, that variable is independent
of the processing.
If the variable's value can change as a result of the processing, the variable is process
dependent.
A predicate whose truth value can change as a result of the processing is said to be
process dependent and one whose truth value does not change as a result of the
processing is process independent.
Process dependence of a predicate does not always follow from dependence of the input
variables on which that predicate is based.

CORRELATION OF VARIABLES AND PREDICATES:


Two variables are correlated if every combina琀椀on of their values cannot be independently speci昀椀ed.
Variables whose values can be speci昀椀ed independently without restric琀椀on are called uncorrelated.
A pair of predicates whose outcomes depend on one or more variables in common are said to be correlated
predicates.
For example, the predicate X==Y is followed by another predicate X+Y == 8. If we select X and Y values to sa琀椀sfy
the 昀椀rst predicate, we might have forced the 2nd predicate's truth value to change.
Every path through a rou琀椀ne is achievable only if all the predicates in that rou琀椀ne are
uncorrelated.

PATH PREDICATE EXPRESSIONS:


A path predicate expression is a set of boolean expressions, all of which must be sa琀椀s昀椀ed
to achieve the selected path.
Example:
X1+3X2+17>=0 X3=17
X4-X1>=14X2

31

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Any set of input values that sa琀椀sfy all of the condi琀椀ons of the path predicate expression
will force the rou琀椀ne to the path.
Some琀椀mes a predicate can have an OR in it.
Example:
A: X5 > 0 E: X6 < 0
B: X1 + 3X2 + 17 B: X1 + 3X2 + 17
>= 0 >= 0
C: X3 = 17 C: X3 = 17
D: X4 - X1 >= D: X4 - X1 >=
14X2 14X2
Boolean algebra nota琀椀on to denote the boolean expression:
ABCD+EBCD=(A+E)BCD

PREDICATE COVERAGE:
Compound Predicate: Predicates of the form A OR B, A AND B and more complicated
Boolean expressions are called as compound predicates.
Some琀椀mes even a simple predicate becomes compound a昀琀er interpreta琀椀on. Example: the
predicate if (x=17) whose opposite branch is if x.NE.17 which is equivalent to x>17. Or.
X<17.
Predicate coverage is being the achieving of all possible combina琀椀ons of truth values
corresponding to the selected path have been explored under some test.
As achieving the desired direc琀椀on at a given decision could s琀椀ll hide bugs in the associated
predicates

TESTING BLINDNESS:
Tes琀椀ng Blindness is a pathological (harmful) situa琀椀on in which the desired path is achieved
for the wrong reason.
There are three types of Tes琀椀ng Blindness:

Assignment Blindness:
o Assignment blindness occurs when the buggy predicate appears to work correctly
because the speci昀椀c value chosen for an assignment statement works with both the
correct and incorrect predicate.
o For Example:
Correct Buggy
X = 7 X = 7
........ ........
if Y > 0 if X+Y > 0
then ... then ...
o If the test case sets Y=1 the desired path is taken in either case, but there is s琀椀ll a bug.
Equality Blindness:
o Equality blindness occurs when the path selected by a prior predicate results in a value

32

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

that works both for the correct and buggy predicate.


o For Example:
Correct Buggy
if Y = 2 then if Y = 2 then
........ ........
if X+Y > 3 if X > 1
then ... then ...
o The 昀椀rst predicate if y=2 forces the rest of the path, so that for any posi琀椀ve value of x.
the path taken at the second predicate will be the same for the correct and buggy
version.

Self Blindness:
o Self blindness occurs when the buggy predicate is a mul琀椀ple of the correct predicate and
as a result is indis琀椀nguishable along that path.
o For Example:

Correct Buggy
X=A X=A
........ ........
if X-1 > 0 if X+A-2 > 0
then ... then ...
1. The assignment (x=a) makes the predicates mul琀椀ples of each other, so the direc琀椀on taken is the same for the
correct and buggy version.

PATH SENSITIZING:

o Review: achievable and unachievable paths:


1. We want to select and test enough paths to achieve a sa琀椀sfactory no琀椀on of
test completeness such as C1+C2.
2. Extract the programs control 昀氀ow graph and select a set of tenta琀椀ve covering paths.
3. For any path in that set, interpret the predicates along the path as needed to express them
in terms of the input vector. In general individual predicates are compound or may
become compound as a result of interpreta琀椀on.
4. Trace the path through, mul琀椀plying the individual compound predicates to achieve
a boolean expression such as
(A+BC) (D+E) (FGH) (IJ) (K) (l) (L).
5. Mul琀椀ply out the expression to achieve a sum of products form:
ADFGHIJKL+AEFGHIJKL+BCDFGHIJKL+BCEFGHIJKL
6. Each product term denotes a set of inequali琀椀es that if solved will yield an input vector that
will drive the rou琀椀ne along the designated path.
7. Solve any one of the inequality sets for the chosen path and you have found a set of input
values for the path.
8. If you can 昀椀nd a solu琀椀on, then the path is achievable.
9. If you can’t 昀椀nd a solu琀椀on to any of the sets of inequali琀椀es, the path is un achievable.
10. The act of 昀椀nding a set of solu琀椀ons to the path predicate expression is called PATH
33

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

SENSITIZATION.

34

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

o HEURISTIC PROCEDURES FOR SENSITIZING PATHS:

1. This is a workable approach, instead of selec琀椀ng the paths without considering how to
sensi琀椀ze, a琀琀empt to choose a covering path set that is easy to sensi琀椀ze and pick hard to
sensi琀椀ze paths only as you must to achieve coverage.
2. Iden琀椀fy all variables that a昀昀ect the decision.
3. Classify the predicates as dependent or independent.
4. Start the path selec琀椀on with un correlated, independent predicates.
5. If coverage has not been achieved using independent uncorrelated predicates, extend the
path set using correlated predicates.
6. If coverage has not been achieved extend the cases to those that involve dependent
predicates.
7. Last, use correlated, dependent predicates.

PATH INSTRUMENTATION:

1. Path instrumenta琀椀on is what we have to do to con昀椀rm that the outcome was achieved
by the intended path.
2. Co-incidental Correctness: The coincidental correctness stands for achieving the desired
outcome for wrong reason.

Figure 2.11: Coincidental Correctness


The above 昀椀gure is an example of a rou琀椀ne that, for the (unfortunately) chosen input value (X
= 16), yields the same outcome (Y = 2) no ma琀琀er which case we select. Therefore, the tests chosen this way will
not tell us whether we have achieved coverage. For example, the 昀椀ve cases could be totally jumbled and s琀椀ll
the outcome would be the same. Path Instrumenta琀椀on is what we have to do to con昀椀rm that the outcome was
achieved by the intended path.
The types of instrumenta琀椀on methods include:

35

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

1. Interpretive Trace Program:


o An interpre琀椀ve trace program is one that executes every statement in order and
records the intermediate values of all calcula琀椀ons, the statement labels traversed etc.
o If we run the tested rou琀椀ne under a trace, then we have all the informa琀椀on we need to
con昀椀rm the outcome and, furthermore, to con昀椀rm that it was achieved by the intended
path.
o The trouble with traces is that they give us far more informa琀椀on than we need. In fact,
the typical trace program provides so much informa琀椀on that con昀椀rming the path from
its massive output dump is more work than simula琀椀ng the computer by hand to
con昀椀rm the path.

2. Traversal Marker or Link Marker:


o A simple and e昀昀ec琀椀ve form of instrumenta琀椀on is called a traversal marker or link marker.
o Name every link by a lower case le琀琀er.
o Instrument the links so that the link's name is recorded when the link is executed.
o The succession of le琀琀ers produced in going from the rou琀椀ne's entry to its exit should, if
there are no bugs, exactly correspond to the path name.

Figure 2.12: Single Link Marker Instrumentation

o Why Single Link Markers aren't enough: Unfortunately, a single link marker may not
do the trick because links can be chewed by open bugs.

Figure 2.13: Why Single Link Markers aren't enough.

36

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

We intended to traverse the ikm path, but because of a rampaging GOTO in the middle of the m link, we go
to process B. If coincidental correctness is against us, the outcomes will be the same and we won't know
about the bug.

Two Link Marker Method:


The solu琀椀on to the problem of single link marker method is to implement two markers per link: one at the
beginning of each link and on at the end.
The two link markers now specify the path name and con昀椀rm both the beginning and end of the link.

Figure 2.14: Double Link Marker Instrumentation

Link Counter: A less disrup琀椀ve (and less informa琀椀ve) instrumenta琀椀on method is based
on counters. Instead of a unique link name to be pushed into a string when the link is
traversed, we simply increment a link counter. We now con昀椀rm that the path length is as
expected. The same problem that led us to double link markers also leads us to double
link counters.

37

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

UNIT II
TRANSACTION FLOW TESTING AND DATA FLOW TESTING
Transac琀椀on Flow Tes琀椀ng:-transac琀椀on 昀氀ows, transac琀椀on 昀氀ow tes琀椀ng
techniques. Data昀氀ow tes琀椀ng:- Basics of data昀氀ow tes琀椀ng, strategies in
data昀氀ow tes琀椀ng, applica琀椀on of data昀氀ow tes琀椀ng.

INTRODUCTION

o A transac琀椀on is a unit of work seen from a system user's point of view.


o A transac琀椀on consists of a sequence of opera琀椀ons, some of which are
performed by a system, persons or devices that are outside of the system.
o Transac琀椀on begins with Birth-that is they are created as a result of some
external act.
o At the conclusion of the transac琀椀on's processing, the transac琀椀on is no longer
in the system.
o Example of a transac琀椀on: A transac琀椀on for an online informa琀椀on retrieval
system might consist of the following steps or tasks:
 Accept input (tenta琀椀ve birth)
 Validate input (birth)
 Transmit acknowledgement to requester
 Do input processing
 Search 昀椀le
 Request direc琀椀ons from user
 Accept input
 Validate input
 Process request
 Update 昀椀le
 Transmit output
 Record transac琀椀on in log and clean up (death)

 TRANSACTION FLOW GRAPHS:

o Transac琀椀on 昀氀ows are introduced as a representa琀椀on of a system's processing.


o The methods that were applied to control 昀氀ow graphs are then used
for func琀椀onal tes琀椀ng.
o Transac琀椀on 昀氀ows and transac琀椀on 昀氀ow tes琀椀ng are to the independent system
tester what control 昀氀ows are path tes琀椀ng are to the programmer.
o The transac琀椀on 昀氀ow graph is to create a behavioral model of the program
that leads to func琀椀onal tes琀椀ng.
o The transac琀椀on 昀氀owgraph is a model of the structure of the system's behavior
(func琀椀onality).
o An example of a Transac琀椀on Flow is as follows:

38

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 3.1: An Example of a Transaction Flow

 USAGE:
o Transac琀椀on 昀氀ows are indispensable for specifying requirements of complicated
systems, especially online systems.
o A big system such as an air tra昀케c control or airline reserva琀椀on system, has not
hundreds, but thousands of di昀昀erent transac琀椀on 昀氀ows.
o The 昀氀ows are represented by rela琀椀vely simple 昀氀owgraphs, many of which have a
single straight-through path.
o Loops are infrequent compared to control 昀氀owgraphs.
o The most common loop is used to request a retry a昀琀er user input errors. An ATM
system, for example, allows the user to try, say three 琀椀mes, and will take the
card away the fourth 琀椀me.

 COMPLICATIONS:
o In simple cases, the transac琀椀ons have a unique iden琀椀ty from the 琀椀me they're
created to the 琀椀me they're completed.
o In many systems the transac琀椀ons can give birth to others, and transac琀椀ons can
also merge.
o Births: There are three di昀昀erent possible interpreta琀椀ons of the decision symbol,
or nodes with two or more out links. It can be a Decision, Biosis or a Mitosis.
1. Decision: Here the transac琀椀on will take one alterna琀椀ve or the other
alterna琀椀ve but not both. (See Figure 3.2 (a))
2. Biosis: Here the incoming transac琀椀on gives birth to a new transac琀椀on,
and both transac琀椀on con琀椀nue on their separate paths, and the parent
retains it iden琀椀ty. (See Figure 3.2 (b))
3. Mitosis: Here the parent transac琀椀on is destroyed and two new
transac琀椀ons are created.(See Figure 3.2 (c))

39

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 3.2: Nodes with multiple outlinks


Mergers: Transac琀椀on 昀氀ow junc琀椀on points are poten琀椀ally as troublesome as transac琀椀on 昀氀ow splits. There are three
types of junc琀椀ons: (1) Ordinary Junc琀椀on (2) Absorp琀椀on (3) Conjuga琀椀on
1 Ordinary Junc琀椀on: An ordinary junc琀椀on which is similar to the junc琀椀on in a control 昀氀ow
graph. A transac琀椀on can arrive either on one link or the other. (See Figure 3.3 (a))
2 Absorp琀椀on: In absorp琀椀on case, the predator transac琀椀on absorbs prey transac琀椀on. The
prey gone but the predator retains its iden琀椀ty. (See Figure 3.3 (b))
3 Conjuga琀椀on: In conjuga琀椀on case, the two parent transac琀椀ons merge to form a new
daughter. In keeping with the biological 昀氀avor this case is called as conjuga琀椀on.(See Figure
3.3 (c))

Figure 3.3: Transaction Flow Junctions and Mergers


We have no problem with ordinary decisions and junc琀椀ons. Births, absorp琀椀ons, and conjuga琀椀ons are as
problema琀椀c for the so昀琀ware designer as they are for the so昀琀ware modeler and the test designer; as a
consequence, such points have more than their share of bugs. The common problems are: lost daughters,
wrongful deaths, and illegi琀椀mate births.

TRANSACTION FLOW TESTING TECHNIQUES:

GET THE TRANSACTIONS FLOWS:


o Complicated systems that process a lot of di昀昀erent, complicated transac琀椀ons
should have explicit representa琀椀ons of the transac琀椀ons 昀氀ows, or the equivalent.
o Transac琀椀on 昀氀ows are like control 昀氀ow graphs, and consequently we
should expect to have them in increasing levels of detail.
o The system's design documenta琀椀on should contain an overview sec琀椀on that
details the main transac琀椀on 昀氀ows.
o Detailed transac琀椀on 昀氀ows are a mandatory pre requisite to the ra琀椀onal design
of a system's func琀椀onal test.

INSPECTIONS, REVIEWS AND WALKTHROUGHS:


o Transac琀椀on 昀氀ows are natural agenda for system reviews or inspec琀椀ons.
o In conduc琀椀ng the walkthroughs, you should:

40

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 Discuss enough transac琀椀on types to account for 98%-99% of the


transac琀椀on the system is expected to process.
 Discuss paths through 昀氀ows in func琀椀onal rather than technical terms.
 Ask the designers to relate every 昀氀ow to the speci昀椀ca琀椀on and to show
how that transac琀椀on, directly or indirectly, follows from the
requirements.
o Make transac琀椀on 昀氀ow tes琀椀ng the corner stone of system func琀椀onal tes琀椀ng just
as path tes琀椀ng is the corner stone of unit tes琀椀ng.
o Select addi琀椀onal 昀氀ow paths for loops, extreme values, and domain boundaries.
o Design more test cases to validate all births and deaths.
o Publish and distribute the selected test paths through the transac琀椀on 昀氀ows as
early as possible so that they will exert the maximum bene昀椀cial e昀昀ect on the
project.
PATH SELECTION:
o Select a set of covering paths (c1+c2) using the analogous criteria you used for
structural path tes琀椀ng.
o Select a covering set of paths based on func琀椀onally sensible transac琀椀ons as you
would for control 昀氀ow graphs.
o Try to 昀椀nd the most tortuous, longest, strangest path from the entry to the exit
of the transac琀椀on 昀氀ow.

PATH SENSITIZATION:
o Most of the normal paths are very easy to sensi琀椀ze-80% - 95% transac琀椀on 昀氀ow
coverage (c1+c2) is usually easy to achieve.
o The remaining small percentage is o昀琀en very di昀케cult.
o Sensi琀椀za琀椀on is the act of de昀椀ning the transac琀椀on. If there are sensi琀椀za琀椀on
problems on the easy paths, then bet on either a bug in transac琀椀on 昀氀ows or a
design bug.

PATH INSTRUMENTATION:
o Instrumenta琀椀on plays a bigger role in transac琀椀on 昀氀ow tes琀椀ng than in unit path
tes琀椀ng.
o The informa琀椀on of the path taken for a given transac琀椀on must be kept with that
transac琀椀on and can be recorded by a central transac琀椀on dispatcher or by the
individual processing modules.
o In some systems, such traces are provided by the opera琀椀ng systems or a running
log.

BASICS OF DATA FLOW TESTING:

DATA FLOW TESTING:


o Data 昀氀ow tes琀椀ng is the name given to a family of test strategies based on
selec琀椀ng paths through the program's control 昀氀ow in order to explore sequences
of events related to the status of data objects.
o For example, pick enough paths to assure that every data object has been
41

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

ini琀椀alized prior to use or that all de昀椀ned objects have been used for something.
o Mo琀椀va琀椀on: It is our belief that, just as one would not feel con昀椀dent about a
program without execu琀椀ng every statement in it as part of some test, one should
not feel con昀椀dent about a program without having seen the e昀昀ect of using the value produced by each and every
computa琀椀on.

DATA FLOW MACHINES:


o There are two types of data 昀氀ow machines with di昀昀erent architectures. (1) Von
Neumann machines (2) Mul琀椀-instruc琀椀on, mul琀椀-data machines (MIMD).
o Von Neumann Machine Architecture:
 Most computers today are von-neumann machines.
 This architecture features interchangeable storage of instruc琀椀ons and
data in the same memory units.
 The Von Neumann machine Architecture executes one instruc琀椀on at a
琀椀me in the following, micro instruc琀椀on sequence:
 Fetch instruc琀椀on from memory
 Interpret instruc琀椀on
 Fetch operands
 Process or Execute
 Store result
 Increment program counter
 GOTO 1
o Multi-instruction, Multi-data machines (MIMD) Architecture:
 These machines can fetch several instruc琀椀ons and objects in parallel.
 They can also do arithme琀椀c and logical opera琀椀ons simultaneously on
di昀昀erent data objects.
 The decision of how to sequence them depends on the compiler.

BUG ASSUMPTION:
The bug assump琀椀on for data-昀氀ow tes琀椀ng strategies is that control 昀氀ow is generally correct and that
something has gone wrong with the so昀琀ware so that data objects are not available when they should be,
or silly things are being done to data objects.
o Also, if there is a control-昀氀ow problem, we expect it to have symptoms that
can be detected by data-昀氀ow analysis.
o Although we'll be doing data-昀氀ow tes琀椀ng, we won't be using data 昀氀ow graphs as
such. Rather, we'll use an ordinary control 昀氀ow graph annotated to show what
happens to the data objects of interest at the moment.
DATA FLOW GRAPHS:
o The data 昀氀ow graph is a graph consis琀椀ng of nodes and directed links.
o We will use a control graph to show what happens to data objects of interest at
that moment.
o Our objec琀椀ve is to expose devia琀椀ons between the data 昀氀ows we have and
the data 昀氀ows we want.

42

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 3.4: Example of a data flow graph

o Data Object State and Usage:


 Data Objects can be created, killed and used.
 They can be used in two dis琀椀nct ways: (1) In a Calcula琀椀on (2) As a part
of a Control Flow Predicate.
 The following symbols denote these possibili琀椀es:
1. De昀椀ned: d - de昀椀ned, created, ini琀椀alized etc
2. Killed or unde昀椀ned: k - killed, unde昀椀ned, released etc
3. Usage: u - used for something (c - used in Calcula琀椀ons, p - used
in a predicate)
 1. Defined (d):
 An object is de昀椀ned explicitly when it appears in a
data declara琀椀on.
 Or implicitly when it appears on the le昀琀 hand side of
the assignment.
 It is also to be used to mean that a 昀椀le has been opened.
 A dynamically allocated object has been allocated.
 Something is pushed on to the stack.
 A record wri琀琀en.
2. Killed or Undefined (k):
 An object is killed on unde昀椀ned when it is released or
otherwise made unavailable.

43

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 When its contents are no longer known with cer琀椀tude (with


absolute certainty / perfectness).
 Release of dynamically allocated objects back to the availability
pool.
 Return of records.
 The old top of the stack a昀琀er it is popped.
 An assignment statement can kill and rede昀椀ne immediately. For
example, if A had been previously de昀椀ned and we do a new
assignment such as A : = 17, we have killed A's previous value and
rede昀椀ned A
3. Usage (u):
 A variable is used for computa琀椀on (c) when it appears on the
right hand side of an assignment statement.
 A 昀椀le record is read or wri琀琀en.
 It is used in a Predicate (p) when it appears directly in a predicate.

DATA FLOW ANOMALIES:


An anomaly is denoted by a two-character sequence of ac琀椀ons. For example, ku means that the object is killed and
then used, where as dd means that the object is de昀椀ned twice without an intervening usage.
What is an anomaly is depend on the applica琀椀on.
There are nine possible two-le琀琀er combina琀椀ons for d, k and u. some are bugs, some are suspicious, and some are
okay.

1 dd :- probably harmless but suspicious. Why de昀椀ne the object twice without an intervening
usage?
2 dk :- probably a bug. Why de昀椀ne the object without using it?
3 du :- the normal case. The object is de昀椀ned and then used.
4 kd :- normal situa琀椀on. An object is killed and then rede昀椀ned.
5 kk :- harmless but probably buggy. Did you want to be sure it was really killed?
6 ku :- a bug. the object doesnot exist.
7 ud :- usually not a bug because the language permits reassignment at almost any 琀椀me.
8 uk :- normal situa琀椀on.
9 uu :- normal situa琀椀on.

In addi琀椀on to the two le琀琀er situa琀椀ons, there are six single le琀琀er situa琀椀ons.We will use a leading dash to mean that
nothing of interest (d,k,u) occurs prior to the ac琀椀on noted along the entry-exit path of interest.
A trailing dash to mean that nothing happens a昀琀er the point of interest to the exit.
They possible anomalies are:
1 -k :- possibly anomalous because from the entrance to this point on the path, the
variable had not been de昀椀ned. We are killing a variable that does not exist.
2 -d :- okay. This is just the 昀椀rst de昀椀ni琀椀on along this path.
3 -u :- possibly anomalous. Not anomalous if the variable is global and has
been previously de昀椀ned.

44

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

4 k- :- not anomalous. The last thing done on this path was to kill the variable.
5 d- :- possibly anomalous. The variable was de昀椀ned and not used on this path. But
this could be a global de昀椀ni琀椀on.
6 u- :- not anomalous. The variable was used but not killed on this path. Although
this sequence is not anomalous, it signals a frequent kind of bug. If d and k mean
dynamic storage alloca琀椀on and return respec琀椀vely, this could be an instance in
which a dynamically allocated object was not returned to the pool a昀琀er use.

DATA FLOW ANOMALY STATE GRAPH:

Data 昀氀ow anomaly model prescribes that an object can be in one of four dis琀椀nct states:
0. K :- unde昀椀ned, previously killed, doesnot exist
1. D :- de昀椀ned but not yet used for anything
2. U :- has been used for computa琀椀on or in predicate
3. A :- anomalous
These capital le琀琀ers (K, D, U, A) denote the state of the variable and should not be confused with the program
ac琀椀on, denoted by lower case le琀琀ers.
Unforgiving Data - Flow Anomaly Flow Graph: Unforgiving model, in which once a variable becomes
anomalous it can never return to a state of grace.

Figure 3.5: Unforgiving Data Flow Anomaly State Graph

Assume that the variable starts in the K state - that is, it has not been de昀椀ned or does not exist. If an a琀琀empt is
made to use it or to kill it (e.g., say that we're talking about opening, closing, and using 昀椀les and that 'killing' means
closing), the object's state becomes anomalous (state A) and, once it is anomalous, no ac琀椀on can return the
variable to a working state.

If it is de昀椀ned (d), it goes into the D, or de昀椀ned but not yet used, state. If it has been de昀椀ned (D) and rede昀椀ned (d)
or killed without use (k), it becomes anomalous, while usage (u) brings it to the U state. If in U, rede昀椀ni琀椀on (d)
brings it to D, u keeps it in U, and k kills it.

Forgiving Data - Flow Anomaly Flow Graph: Forgiving model is an alternate model where
redemp琀椀on (recover) from the anomalous state is possible

45

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 3.6: Forgiving Data Flow Anomaly State Graph


This graph has three normal and three anomalous states and he considers the kk sequence not to be anomalous.
The di昀昀erence between this state graph and Figure 3.5 is that redemp琀椀on is possible. A proper ac琀椀on from any of
the three anomalous states returns the variable to a useful working state.

The point of showing you this alterna琀椀ve anomaly state graph is to demonstrate that the speci昀椀cs of an anomaly
depends on such things as language, applica琀椀on, context, or even your frame of mind. In principle, you must
create a new de昀椀ni琀椀on of data 昀氀ow anomaly (e.g., a new state graph) in each situa琀椀on. You must at least verify
that the anomaly de昀椀ni琀椀on behind the theory or imbedded in a data 昀氀ow anomaly test tool is appropriate to your
situa琀椀on.

STATIC Vs DYNAMIC ANOMALY DETECTION:

Sta琀椀c analysis is analysis done on source code without actually execu琀椀ng it. For example: source code syntax error
detec琀椀on is the sta琀椀c analysis result.

Dynamic analysis is done on the 昀氀y as the program is being executed and is based on intermediate values that
result from the program's execu琀椀on. For example: a division by zero warning is the dynamic result.

If a problem, such as a data 昀氀ow anomaly, can be detected by sta琀椀c analysis methods, then it doesn’t belongs in
tes琀椀ng - it belongs in the language processor.
There is actually a lot more sta琀椀c analysis for data 昀氀ow analysis for data 昀氀ow anomalies going on in current
language processors.

For example, language processors which force variable declara琀椀ons can detect (-u) and (ku) anomalies.But s琀椀ll
there are many things for which current no琀椀ons of sta琀椀c analysis are INADEQUATE.

Why Sta琀椀c Analysis isn't enough? There are many things for which current no琀椀ons of sta琀椀c
analysis are inadequate. They are:

46

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 Dead Variables: Although it is o昀琀en possible to prove that a variable is dead or alive at a
given point in the program, the general problem is unsolvable.

 Arrays: Arrays are problema琀椀c in that the array is de昀椀ned or killed as a single object, but
reference is to speci昀椀c loca琀椀ons within the array. Array pointers are usually dynamically
calculated, so there's no way to do a sta琀椀c analysis to validate the pointer value. In many
languages, dynamically allocated arrays contain garbage unless explicitly ini琀椀alized and
therefore, -u anomalies are possible.

 Records and Pointers: The array problem and the di昀케culty with pointers is a special case of
mul琀椀part data structures. We have the same problem with records and the pointers to
them. Also, in many applica琀椀ons we create 昀椀les and their names dynamically and there's no
way to determine, without execu琀椀on, whether such objects are in the proper state on a
given path or, for that ma琀琀er, whether they exist at all.

 Dynamic Subrou琀椀ne and Func琀椀on Names in a Call: subrou琀椀ne or func琀椀on name is a


dynamic variable in a call. What is passed, or a combina琀椀on of subrou琀椀ne names and data
objects, is constructed on a speci昀椀c path. There's no way, without execu琀椀ng the path, to
determine whether the call is correct or not.

 False Anomalies: Anomalies are speci昀椀c to paths. Even a "clear bug" such as ku may not be
a bug if the path along which the anomaly exist is unachievable. Such "anomalies" are false
anomalies. Unfortunately, the problem of determining whether a path is or is not
achievable is unsolvable.

 Recoverable Anomalies and Alternate State Graphs: What cons琀椀tutes an anomaly depends
on context, applica琀椀on, and seman琀椀cs. How does the compiler know which model I have in
mind? It can't because the de昀椀ni琀椀on of "anomaly" is not fundamental. The language
processor must have a built-in anomaly de昀椀ni琀椀on with which you may or may not (with
good reason) agree.

 Concurrency, Interrupts, System Issues: As soon as we get away from the simple single-
task uniprocessor environment and start thinking in terms of systems, most anomaly issues
become vastly more complicated.

How o昀琀en do we de昀椀ne or create data objects at an interrupt level so that they can be processed by a lower-
priority rou琀椀ne? Interrupts can make the "correct" anomalous and the "anomalous" correct. True concurrency
(as in an MIMD machine) and pseudo concurrency (as in mul琀椀processing) systems can do the same to us.
Much of integra琀椀on and system tes琀椀ng is aimed at detec琀椀ng data-昀氀ow anomalies that cannot be detected in
the context of a single rou琀椀ne.

Although sta琀椀c analysis methods have limits, they are worth using and a con琀椀nuing trend in language
processor design has been be琀琀er sta琀椀c analysis methods, especially for data 昀氀ow anomaly detec琀椀on. That's
good because it means there's less for us to do as testers and we have far too much to do as it is.

47

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

DATA FLOW MODEL:

The data 昀氀ow model is based on the program's control 昀氀ow graph - Don't confuse that with the program's data
昀氀ow graph.
Here we annotate each link with symbols (for example, d, k, u, c, and p) or sequences of symbols (for example, dd,
du, ddd) that denote the sequence of data opera琀椀ons on that link with respect to the variable of interest. Such
annota琀椀ons are called link weights.
The control 昀氀ow graph structure is same for every variable: it is the weights that change.

Components of the model:


1. To every statement there is a node, whose name is unique. Every node has at least one
outlink and at least one inlink except for exit nodes and entry nodes.
2. Exit nodes are dummy nodes placed at the outgoing arrowheads of exit statements
(e.g., END, RETURN), to complete the graph. Similarly, entry nodes are dummy nodes
placed at entry statements (e.g., BEGIN) for the same reason.
3. The outlink of simple statements (statements with only one outlink) are weighted by the
proper sequence of data-昀氀ow ac琀椀ons for that statement. Note that the sequence can
consist of more than one le琀琀er. For example, the assignment statement A:= A + B in
most languages is weighted by cd or possibly ckd for variable A. Languages that permit
mul琀椀ple simultaneous assignments and/or compound statements can have anomalies
within the statement. The sequence must correspond to the order in which the object
code will be executed for that variable.
4. Predicate nodes (e.g., IF-THEN-ELSE, DO WHILE, CASE) are weighted with the p - use(s)
on every outlink, appropriate to that outlink.
5. Every sequence of simple statements (e.g., a sequence of nodes with one inlink and one
outlink) can be replaced by a pair of nodes that has, as weights on the link between
them, the concatena琀椀on of link weights.
6. If there are several data-昀氀ow ac琀椀ons on a given link for a given variable, then the weight
of the link is denoted by the sequence of ac琀椀ons on that link for that variable.
7. Conversely, a link with several data-昀氀ow ac琀椀ons on it can be replaced by a succession of
equivalent links, each of which has at most one data-昀氀ow ac琀椀on for any variable.
Let us consider the example:

Figure 3.7: Program Example (PDL)


48

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 3.8: Unannotated 昀氀ow graph for example program in Figure 3.7

Figure 3.9: Control 昀氀ow graph annotated for X and Y data 昀氀ows.

Figure 3.10: Control 昀氀ow graph annotated for Z data 昀氀ow.

Figure 3.11: Control 昀氀ow graph annotated for V data 昀氀ow.

49

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

STRATEGIES OF DATA FLOW TESTING:

 INTRODUCTION:

o Data Flow Tes琀椀ng Strategies are structural strategies.


o In contrast to the path-tes琀椀ng strategies, data-昀氀ow strategies take into account
what happens to data objects on the links in addi琀椀on to the raw connec琀椀vity of
the graph.
o In other words, data 昀氀ow strategies require data-昀氀ow link weights (d,k,u,c,p).
o Data Flow Tes琀椀ng Strategies are based on selec琀椀ng test path segments (also
called sub paths) that sa琀椀sfy some characteris琀椀c of data 昀氀ows for all data
objects.
o For example, all sub paths that contain a d (or u, k, du, dk).
o A strategy X is stronger than another strategy Y if all test cases produced under Y
are included in those produced under X - conversely for weaker.

 TERMINOLOGY:
1. De昀椀ni琀椀on-Clear Path Segment, with respect to variable X, is a connected
sequence of links such that X is (possibly) de昀椀ned on the 昀椀rst link and not
rede昀椀ned or killed on any subsequent link of that path segment. ll paths in
Figure
3.9 are de昀椀ni琀椀on clear because variables X and Y are de昀椀ned only on the 昀椀rst link (1,3) and not therea昀琀er. In Figure
3.10, we have a more complicated situa琀椀on. The following path segments are de昀椀ni琀椀on-clear: (1,3,4), (1,3,5),
(5,6,7,4), (7,8,9,6,7), (7,8,9,10), (7,8,10), (7,8,10,11). Subpath (1,3,4,5) is not de昀椀ni琀椀on-clear because the variable is
de昀椀ned on (1,3) and again on (4,5). For prac琀椀ce, try 昀椀nding all the de昀椀ni琀椀on-clear subpaths for this rou琀椀ne (i.e., for all
variables).
2. Loop-Free Path Segment is a path segment for which every node in it is visited
atmost once. For Example, path (4,5,6,7,8,10) in Figure 3.10 is loop free, but path
(10,11,4,5,6,7,8,10,11,12) is not because nodes 10 and 11 are each visited twice.
3. Simple path segment is a path segment in which at most one node is visited
twice. For example, in Figure 3.10, (7,4,5,6,7) is a simple path segment. A simple
path segment is either loop-free or if there is a loop, only one node is involved.
4. A du path from node i to k is a path segment such that if the last link has a
computa琀椀onal use of X, then the path is simple and de昀椀ni琀椀on-clear; if the
penul琀椀mate (last but one) node is j - that is, the path is (i,p,q,...,r,s,t,j,k) and link
(j,k) has a predicate use - then the path from i to j is both loop-free and
de昀椀ni琀椀on- clear.

STRATEGIES: The structural test strategies discussed below are based on the program's control 昀氀ow graph. They
di昀昀er in the extent to which predicate uses and/or computa琀椀onal uses of variables are included in the test set.
Various types of data 昀氀ow tes琀椀ng strategies in decreasing order of their e昀昀ec琀椀veness are:

All - du Paths (ADUP): The all-du-paths (ADUP) strategy is the strongest data-昀氀ow tes琀椀ng strategy discussed here.
It requires that every du path from every de昀椀ni琀椀on of every variable to every some test.

50

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

For variable X and Y:In Figure 3.9, because variables X and Y are used only on link (1,3), any test that starts at
the entry sa琀椀s昀椀es this criterion (for variables X and Y, but not for all variables as required by the strategy).

For variable Z: The situa琀椀on for variable Z (Figure 3.10) is more complicated because the variable is rede昀椀ned in
many places. For the de昀椀ni琀椀on on link (1,3) we must exercise paths that include subpaths (1,3,4) and (1,3,5). The
de昀椀ni琀椀on on link (4,5) is covered by any path that includes (5,6), such as subpath (1,3,4,5,6, ...). The (5,6)
de昀椀ni琀椀on requires paths that include subpaths (5,6,7,4) and (5,6,7,8).

For variable V: Variable V (Figure 3.11) is de昀椀ned only once on link (1,3). Because V has a predicate use at node 12
and the subsequent path to the end must be forced for both direc琀椀ons at node 12, the all-du-paths strategy for
this variable requires that we exercise all loop-free entry/exit paths and at least one path that includes the loop
caused by (11,4).

Note that we must test paths that include both subpaths (3,4,5) and (3,5) even though neither of these has V
de昀椀ni琀椀ons. They must be included because they provide alternate du paths to the V use on link (5,6). Although
(7,4) is not used in the test set for variable V, it will be included in the test set that covers the predicate uses of
array variable V() and U.

The all-du-paths strategy is a strong criterion, but it does not take as many tests as it might seem at 昀椀rst because
any one test simultaneously sa琀椀s昀椀es the criterion for several de昀椀ni琀椀ons and uses of several di昀昀erent variables.

All Uses Startegy (AU):The all uses strategy is that at least one de昀椀ni琀椀on clear path from every de昀椀ni琀椀on of every
variable to every use of that de昀椀ni琀椀on be exercised under some test.

Just as we reduced our ambi琀椀ons by stepping down from all paths (P) to branch coverage (C2), say, we can reduce
the number of test cases by asking that the test set should include at least one path segment from every
de昀椀ni琀椀on to every use that can be reached by that de昀椀ni琀椀on.

For variable V: In Figure 3.11, ADUP requires that we include subpaths (3,4,5) and (3,5) in some test because
subsequent uses of V, such as on link (5,6), can be reached by either alterna琀椀ve. In AU either (3,4,5) or (3,5) can be
used to start paths, but we don't have to use both. Similarly, we can skip the (8,10) link if we've included the
(8,9,10) subpath.

Note the hole. We must include (8,9,10) in some test cases because that's the only way to reach the c use at link
(9,10) - but suppose our bug for variable V is on link (8,10) a昀琀er all? Find a covering set of paths under AU for
Figure 3.11.

All p-uses/some c-uses strategy (APU+C) : For every variable and every de昀椀ni琀椀on of that variable, include at least
one de昀椀ni琀椀on free path from the de昀椀ni琀椀on to every predicate use; if there are de昀椀ni琀椀ons of the variables that are
not covered by the above prescrip琀椀on, then add computa琀椀onal use test cases as required to cover every
de昀椀ni琀椀on.

51

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

For variable Z:In Figure 3.10, for APU+C we can select paths that all take the upper link (12,13) and therefore we do
not cover the c-use of Z: but that's okay according to the strategy's de昀椀ni琀椀on because every de昀椀ni琀椀on is covered.

Links (1,3), (4,5), (5,6), and (7,8) must be included because they contain de昀椀ni琀椀ons for variable
Z. Links (3,4), (3,5), (8,9), (8,10), (9,6), and (9,10) must be included because they contain
predicate uses of Z. Find a covering set of test cases under APU+C for all variables inthis
example - it only takes two tests.

For variable V:In Figure 3.11, APU+C is achieved for V by (1,3,5,6,7,8,10,11,4,5,6,7,8,10,11,12[upper], 13,2) and
(1,3,5,6,7,8,10,11,12[lower], 13,2). Note
that the c-use at (9,10) need not be included under the APU+C criterion.

All c-uses/some p-uses strategy (ACU+P) : The all c-uses/some p-uses strategy (ACU+P) is to 昀椀rst ensure coverage
by computa琀椀onal use cases and if any de昀椀ni琀椀on is not covered by the previously selected paths, add such
predicate use cases as are needed to assure that every de昀椀ni琀椀on is included in some test.

For variable Z: In Figure 3.10, ACU+P coverage is achieved for Z by path (1,3,4,5,6,7,8,10, 11,12,13[lower], 2), but
the predicate uses of several de昀椀ni琀椀ons are not covered. Speci昀椀cally, the (1,3) de昀椀ni琀椀on is not covered for the
(3,5) p-use, the (7,8) de昀椀ni琀椀on is not covered for the (8,9), (9,6) and (9, 10) p-uses.

The above examples imply that APU+C is stronger than branch coverage but ACU+P may be weaker than, or
incomparable to, branch coverage.

All De昀椀ni琀椀ons Strategy (AD) : The all de昀椀ni琀椀ons strategy asks only every de昀椀ni琀椀on of every variable be covered by
atleast one use of that variable, be that use a computa琀椀onal use or a predicate use.

For variable Z: Path (1,3,4,5,6,7,8, . . .) sa琀椀s昀椀es this criterion for variable Z, whereas any entry/exit path
sa琀椀s昀椀es it for variable V.
From the de昀椀ni琀椀on of this strategy we would expect it to be weaker than both ACU+P and APU+C.

1. All Predicate Uses (APU), All Computa琀椀onal Uses (ACU) Strategies : The all predicate uses
strategy is derived from APU+C strategy by dropping the requirement that we include a c- use
for the variable if there are no p-uses for the variable. The all computa琀椀onal uses strategy is
derived from ACU+P strategy by dropping the requirement that we include a p-use for the
variable if there are no c-uses for the variable.

It is intui琀椀vely obvious that ACU should be weaker than ACU+P and that APU should be weaker than APU+C.

52

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

ORDERING THE STRATEGIES:

Figure 3.12compares path-昀氀ow and data-昀氀ow tes琀椀ng strategies. The arrows denote that the strategy at the
arrow's tail is stronger than the strategy at the arrow's head

Figure 3.12: Relative Strength of Structural Test Strategies.


o The right-hand side of this graph, along the path from "all paths" to "all
statements" is the more interes琀椀ng hierarchy for prac琀椀cal applica琀椀ons.
o Note that although ACU+P is stronger than ACU, both are incomparable to the
predicate-biased strategies. Note also that "all de昀椀ni琀椀ons" is not comparable to
ACU or APU.

SLICING AND DICING:

o A (sta琀椀c) program slice is a part of a program (e.g., a selected set of statements)


de昀椀ned with respect to a given variable X (where X is a simple variable or a data
vector) and a statement i: it is the set of all statements that could (poten琀椀ally,
under sta琀椀c analysis) a昀昀ect the value of X at statement i - where the in昀氀uence of
a faulty statement could result from an improper computa琀椀onal use or predicate
use of some other variables at prior statements.
o If X is incorrect at statement i, it follows that the bug must be in the program
slice for X with respect to i
o A program dice is a part of a slice in which all statements which are known to be
correct have been removed.
o In other words, a dice is obtained from a slice by incorpora琀椀ng informa琀椀on
obtained through tes琀椀ng or experiment (e.g., debugging).

53

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

o The debugger 昀椀rst limits her scope to those prior statements that could have
caused the faulty value at statement i (the slice) and then eliminates from
further considera琀椀on those statements that tes琀椀ng has shown to be correct.
o Debugging can be modeled as an itera琀椀ve procedure in which slices are further
re昀椀ned by dicing, where the dicing informa琀椀on is obtained from ad hoc tests
aimed primarily at elimina琀椀ng possibili琀椀es. Debugging ends when the dice has
been reduced to the one faulty statement.

o Dynamic slicing is a re昀椀nement of sta琀椀c slicing in which only statements on


achievable paths to the statement in ques琀椀on are included.

54

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

UNIT III
DOMAIN TESTING
Domain Tes琀椀ng:-domains and paths, Nice & ugly domains, domain tes琀椀ng, domains and
interfaces tes琀椀ng, domain and interface tes琀椀ng, domains and testability.

DOMAINS AND PATHS:

 INTRODUCTION:
o Domain: In mathema琀椀cs, domain is a set of possible values of
an independent variable or the variables of a func琀椀on.
o Programs as input data classi昀椀ers: domain tes琀椀ng a琀琀empts to determine
whether the classi昀椀ca琀椀on is or is not correct.
o Domain tes琀椀ng can be based on speci昀椀ca琀椀ons or
equivalent implementa琀椀on informa琀椀on.
o If domain tes琀椀ng is based on speci昀椀ca琀椀ons, it is a func琀椀onal test technique.
o If domain tes琀椀ng is based implementa琀椀on details, it is a structural test technique.
o For example, you're doing domain tes琀椀ng when you check extreme values
of an input variable.
All inputs to a program can be considered as if they are numbers. For example, a character string can be
treated as a number by concatena琀椀ng bits and looking at them as if they were a binary integer. This is the
view in domain tes琀椀ng, which is why this strategy has a mathema琀椀cal 昀氀avor.

 THE MODEL: The following 昀椀gure is a schema琀椀c representa琀椀on of domain tes琀椀ng.

Figure 4.1: Schematic Representation of Domain Testing.

o Before doing whatever it does, a rou琀椀ne must classify the input and set
it moving on the right path.
o An invalid input (e.g., value too big) is just a special processing case
called 'reject'.
o The input then passes to a hypothe琀椀cal subrou琀椀ne rather than on calcula琀椀ons.
o In domain tes琀椀ng, we focus on the classi昀椀ca琀椀on aspect of the rou琀椀ne rather
than on the calcula琀椀ons.

55

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

o Structural knowledge is not needed for this model - only a


consistent, complete speci昀椀ca琀椀on of input values for each case.
o We can infer that for each case there must be at least one path to process that case.
 A DOMAIN IS A SET:
o An input domain is a set.
o If the source language supports set de昀椀ni琀椀ons (E.g. PASCAL set types and C
enumerated types) less tes琀椀ng is needed because the compiler does much of it
for us.
o Domain tes琀椀ng does not work well with arbitrary discrete sets of data objects.
o Domain for a loop-free program corresponds to a set of numbers de昀椀ned over
the input vector.

 DOMAINS, PATHS AND PREDICATES:


o In domain tes琀椀ng, predicates are assumed to be interpreted in terms of input
vector variables.
o If domain tes琀椀ng is applied to structure, then predicate interpreta琀椀on must be
based on actual paths through the rou琀椀ne - that is, based on the implementa琀椀on
control 昀氀ow graph.
o Conversely, if domain tes琀椀ng is applied to speci昀椀ca琀椀ons, interpreta琀椀on is based
on a speci昀椀ed data 昀氀ow graph for the rou琀椀ne; but usually, as is the nature of
speci昀椀ca琀椀ons, no interpreta琀椀on is needed because the domains are speci昀椀ed
directly.
o For every domain, there is at least one path through the rou琀椀ne.
o There may be more than one path if the domain consists of disconnected parts
or if the domain is de昀椀ned by the union of two or more domains.
o Domains are de昀椀ned their boundaries. Domain boundaries are also where most
domain bugs occur.
o For every boundary there is at least one predicate that speci昀椀es what numbers belong to the domain and
what numbers don't.
For example, in the statement IF x>0 THEN ALPHA ELSE BETA we know that numbers greater than zero belong to ALPHA
processing domain(s) while zero and smaller numbers belong to BETA domain(s).
o A domain may have one or more boundaries - no ma琀琀er how many variables
de昀椀ne it. For example, if the predicate is x2 + y2 < 16, the domain is the inside of
a circle of radius 4 about the origin. Similarly, we could de昀椀ne a spherical domain
with one boundary but in three variables.
o Domains are usually de昀椀ned by many boundary segments and therefore by
many predicates. i.e. the set of interpreted predicates traversed on that path
(i.e., the path's predicate expression) de昀椀nes the domain's boundaries.

 A DOMAIN CLOSURE:
o A domain boundary is closed with respect to a domain if the points on the
boundary belong to the domain.
o If the boundary points belong to some other domain, the boundary is said to be
open.
o Figure 4.2 shows three situa琀椀ons for a one-dimensional domain - i.e., a domain
de昀椀ned over one input variable; call it x
56

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

The importance of domain closure is that incorrect closure bugs are frequent domain bugs. For example, x >= 0 when x >
0 was intended

Figure 4.2: Open and Closed Domains.


 DOMAIN DIMENSIONALITY:
o Every input variable adds one dimension to the domain.
o One variable de昀椀nes domains on a number line.
o Two variables de昀椀ne planar domains.
o Three variables de昀椀ne solid domains.
o Every new predicate slices through previously de昀椀ned domains and cuts
them in half.
o Every boundary slices through the input vector space with a dimensionality
which is less than the dimensionality of the space.
o Thus, planes are cut by lines and points, volumes by planes, lines and points
and n-spaces by hyperplanes.
 BUG ASSUMPTION:
o The bug assump琀椀on for the domain tes琀椀ng is that processing is okay but
the domain de昀椀ni琀椀on is wrong.
o An incorrectly implemented domain means that boundaries are wrong, which
may in turn mean that control 昀氀ow predicates are wrong.
o Many di昀昀erent bugs can result in domain errors. Some of them are:

Domain Errors:
 Double Zero Representa琀椀on: In computers or Languages that have a
dis琀椀nct posi琀椀ve and nega琀椀ve zero, boundary errors for nega琀椀ve zero are
common.

 Floa琀椀ng point zero check: A 昀氀oa琀椀ng point number can equal zero only if
the previous de昀椀ni琀椀on of that number set it to zero or if it is subtracted
from itself or mul琀椀plied by zero. So the 昀氀oa琀椀ng point zero check to be
done against an epsilon value.

57

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 Contradictory domains: An implemented domain can never be


ambiguous or contradictory, but a speci昀椀ed domain can. A
contradictory
domain speci昀椀ca琀椀on means that at least two supposedly dis琀椀nct domains overlap.

 Ambiguous domains: Ambiguous domains means that union of the


domains is incomplete. That is there are missing domains or holes in the
speci昀椀ed domains. Not specifying what happens to points on the domain
boundary is a common ambiguity.

 Over speci昀椀ed Domains: his domain can be overloaded with so many


condi琀椀ons that the result is a null domain. Another way to put it is to say
that the domain's path is unachievable.

 Boundary Errors: Errors caused in and around the boundary of a domain.


Example, boundary closure bug, shi昀琀ed, 琀椀lted, missing, extra boundary.

 Closure Reversal: A common bug. The predicate is de昀椀ned in terms of


>=. The programmer chooses to implement the logical complement and incorrectly uses
<= for the new predicate; i.e., x >= 0 is incorrectly negated as x <= 0, thereby shi昀琀ing
boundary values to adjacent domains.

 Faulty Logic: Compound predicates (especially) are subject to faulty logic


transforma琀椀ons and improper simpli昀椀ca琀椀on. If the predicates de昀椀ne
domain boundaries, all kinds of domain bugs can result from faulty logic
manipula琀椀ons.

 RESTRICTIONS TO DOMAIN TESTING: Domain tes琀椀ng has restric琀椀ons, as do other


tes琀椀ng techniques. Some of them include:

o Co-incidental Correctness: Domain tes琀椀ng isn't good at 昀椀nding bugs for which
the outcome is correct for the wrong reasons. If we're plagued by coincidental
correctness we may misjudge an incorrect boundary. Note that this implies
weakness for domain tes琀椀ng when dealing with rou琀椀nes that have binary
outcomes (i.e., TRUE/FALSE)

o Representa琀椀ve Outcome: Domain tes琀椀ng is an example of par琀椀琀椀on tes琀椀ng.


Par琀椀琀椀on-tes琀椀ng strategies divide the program's input space into domains such
that all inputs within a domain are equivalent (not equal, but equivalent) in the
sense that any input represents all inputs in that domain.
o If the selected input is shown to be correct by a test, then processing is
presumed correct, and therefore all inputs within that domain are expected
(perhaps unjus琀椀昀椀ably) to be correct. Most test techniques, func琀椀onal or
structural, fall under par琀椀琀椀on tes琀椀ng and therefore make this representa琀椀ve
outcome assump琀椀on. For example, x2 and 2x are equal for x = 2, but the
func琀椀ons are di昀昀erent. The func琀椀onal di昀昀erences between adjacent domains are
usually simple, such as x + 7 versus x + 9, rather than x2 versus 2x.

58

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Simple Domain Boundaries and Compound Predicates: Compound predicates in which


each part of the predicate speci昀椀es a di昀昀erent boundary are not a problem: for example,
x
>= 0 AND x < 17, just speci昀椀es two domain boundaries by one compound predicate. As
an example of a compound predicate that speci昀椀es one boundary, consider: x = 0 AND y
>= 7 AND y <= 14. This predicate speci昀椀es one boundary equa琀椀on (x = 0) but alternates closure, pu琀�ng it
in one or the other domain depending on whether y < 7 or y > 14. Treat compound predicates with respect
because they’re more complicated than they seem.

o Func琀椀onal Homogeneity of Bugs: Whatever the bug is, it will not change the
func琀椀onal form of the boundary predicate. For example, if the predicate is ax >=
b, the bug will be in the value of a or b but it will not change the predicate to
ax
>= b,
say.
o Linear Vector Space: Most papers on domain tes琀椀ng, assume linear boundaries -
not a bad assump琀椀on because in prac琀椀ce most boundary predicates are linear.

o Loop Free So昀琀ware: Loops are problema琀椀c for domain tes琀椀ng. The trouble with
loops is that each itera琀椀on can result in a di昀昀erent predicate expression (a昀琀er
interpreta琀椀on), which means a possible domain boundary change.

NICE AND UGLY DOMAINS:

 NICE DOMAINS:
o Where do these domains come from?
Domains are and will be de昀椀ned by an imperfect itera琀椀ve process aimed at achieving (user, buyer, voter) sa琀椀sfac琀椀on.
o Implemented domains can't be incomplete or inconsistent. Every input will be
processed (rejec琀椀on is a process), possibly forever. Inconsistent domains will be
made consistent.
o Conversely, speci昀椀ed domains can be incomplete and/or inconsistent.
Incomplete in this context means that there are input vectors for which no path
is speci昀椀ed, and inconsistent means that there are at least two contradictory
speci昀椀ca琀椀ons over the same segment of the input space.
o Some important proper琀椀es of nice domains are: Linear, Complete, Systema琀椀c,
And Orthogonal, Consistently closed, Convex and simply connected.
o To the extent that domains have these proper琀椀es domain tes琀椀ng is easy as
tes琀椀ng gets.
o The bug frequency is lesser for nice domain than for ugly domains.

59

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 4.3: Nice Two-Dimensional Domains.


 LINEAR AND NON LINEAR BOUNDARIES:
o Nice domain boundaries are de昀椀ned by linear inequali琀椀es or equa琀椀ons.
o The impact on tes琀椀ng stems from the fact that it takes only two points to
determine a straight line and three points to determine a plane and in general n+
1 point to determine an n-dimensional hyper plane.
o In prac琀椀ce more than 99.99% of all boundary predicates are either linear or can
be linearized by simple variable transforma琀椀ons.

 COMPLETE BOUNDARIES:
o Nice domain boundaries are complete in that they span the number space from
plus to minus in昀椀nity in all dimensions.
o Figure 4.4 shows some incomplete boundaries. Boundaries A and E have gaps.
o Such boundaries can come about because the path that hypothe琀椀cally
corresponds to them is unachievable, because inputs are constrained in such a
way that such values can't exist, because of compound predicates that de昀椀ne a
single boundary, or because redundant predicates convert such boundary values
into a null set.
o The advantage of complete boundaries is that one set of tests is needed to
con昀椀rm the boundary no ma琀琀er how many domains it bounds.
o If the boundary is chopped up and has holes in it, then every segment of that
boundary must be tested for every domain it bounds.

Figure 4.4: Incomplete Domain Boundaries.

 SYSTEMATIC BOUNDARIES:
o Systema琀椀c boundary means that boundary inequali琀椀es related by a simple
func琀椀on such as a constant.
In Figure 4.3 for example, the domain boundaries for u and v di昀昀er only by a
constant.

60

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

o where fi is an arbitrary linear func琀椀on, X is the input vector, ki and c are


constants, and g(i,c) is a decent func琀椀on over i and c that yields a constant, such
as k + ic.
o The 昀椀rst example is a set of parallel lines, and the second example is a set of
systema琀椀cally (e.g., equally) spaced parallel lines (such as the spokes of a wheel,
if equally spaced in angles, systema琀椀c).
o If the boundaries are systema琀椀c and if you have one 琀椀ed down and generate
tests for it, the tests for the rest of the boundaries in that set can be
automa琀椀cally generated.

 ORTHOGONAL BOUNDARIES:
o Two boundary sets U and V (See Figure 4.3) are said to be orthogonal if every
inequality in V is perpendicular to every inequality in U.
o If two boundary sets are orthogonal, then they can be tested independently
o In Figure 4.3 we have six boundaries in U and four in V. We can con昀椀rm the
boundary proper琀椀es in a number of tests propor琀椀onal to 6 + 4 = 10 (O(n)). If we
琀椀lt the boundaries to get Figure 4.5,
o we must now test the intersec琀椀ons. We've gone from a linear number of cases
to a quadra琀椀c: from O(n) to O(n2).

61

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 4.5: Tilted Boundaries.

Figure 4.6: Linear, Non-orthogonal Domain Boundaries.


o Actually, there are two di昀昀erent but related orthogonality condi琀椀ons. Sets of
boundaries can be orthogonal to one another but not orthogonal to the
coordinate axes (condi琀椀on 1), or boundaries can be orthogonal to the coordinate
axes (condi琀椀on 2).

 CLOSURE CONSISTENCY:
o Figure 4.6 shows another desirable domain property: boundary closures are
consistent and systema琀椀c.
o The shaded areas on the boundary denote that the boundary belongs to the
domain in which the shading lies - e.g., the boundary lines belong to the domains
on the right.
o Consistent closure means that there is a simple pa琀琀ern to the closures - for
example, using the same rela琀椀onal operator for all boundaries of a set of parallel
boundaries.

 CONVEX:
o A geometric 昀椀gure (in any number of dimensions) is convex if you can take two
arbitrary points on any two di昀昀erent boundaries, join them by a line and all
points on that line lie within the 昀椀gure.
o Nice domains are convex; dirty domains aren't.
o You can smell a suspected concavity when you see phrases such as: ". . . except if
. . .," "However . . .," ". . . but not......" In programming, it's o昀琀en the buts in the speci昀椀ca琀椀on that kill you.

 SIMPLY CONNECTED:
o Nice domains are simply connected; that is, they are in one piece rather than
pieces all over the place interspersed with other domains.
o Simple connec琀椀vity is a weaker requirement than convexity; if a domain is
convex it is simply connected, but not vice versa.
o Consider domain boundaries de昀椀ned by a compound predicate of the (Boolean)
form ABC. Say that the input space is divided into two domains, one de昀椀ned by

62

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

ABC and, therefore, the other de昀椀ned by its nega琀椀on.


o For example, suppose we de昀椀ne valid numbers as those lying between 10 and 17
inclusive. The invalid numbers are the disconnected domain consis琀椀ng of
numbers less than 10 and greater than 17.
o Simple connec琀椀vity, especially for default cases, may be impossible.

 UGLY DOMAINS:
o Some domains are born ugly and some are ugli昀椀ed by bad speci昀椀ca琀椀ons.
o Every simpli昀椀ca琀椀on of ugly domains by programmers can be either good or bad.
o Programmers in search of nice solu琀椀ons will "simplify" essen琀椀al complexity out
of existence. Testers in search of brilliant insights will be blind to essen琀椀al
complexity and therefore miss important cases.
o If the ugliness results from bad speci昀椀ca琀椀ons and the programmer's
simpli昀椀ca琀椀on is harmless, then the programmer has made ugly good.
o But if the domain's complexity is essen琀椀al (e.g., the income tax code),
such "simpli昀椀ca琀椀ons" cons琀椀tute bugs.
o Nonlinear boundaries are so rare in ordinary programming that there's no
informa琀椀on on how programmers might "correct" such boundaries if they're
essen琀椀al.

 AMBIGUITIES AND CONTRADICTIONS:


o Domain ambigui琀椀es are holes in the input space.
o The holes may lie within the domains or in cracks between domains.
o Two kinds of contradic琀椀ons are possible: overlapped domain speci昀椀ca琀椀ons and
overlapped closure speci昀椀ca琀椀ons
o Figure 4.7c shows overlapped domains and Figure 4.7d shows dual
closure assignment.

Figure 4.7: Domain Ambiguities and Contradictions.

 SIMPLIFYING THE TOPOLOGY:


o The programmer's and tester's reac琀椀on to complex domains is the same - simplify
o There are three generic cases: concavi琀椀es, holes and disconnected pieces.
o Programmers introduce bugs and testers misdesign test cases by: smoothing out
concavi琀椀es (Figure 4.8a), 昀椀lling in holes (Figure 4.8b), and joining disconnected
pieces (Figure 4.8c).

63

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 4.8: Simplifying the topology.


 RECTIFYING BOUNDARY CLOSURES:
o If domain boundaries are parallel but have closures that go every which way
(le昀琀, right, le昀琀 . . .) the natural reac琀椀on is to make closures go the same way (see
Figure 4.9).

Figure 4.9: Forcing Closure Consistency.

DOMAIN TESTING:

 DOMAIN TESTING STRATEGY: The domain-tes琀椀ng strategy is simple, although


possibly tedious (slow).
o Domains are de昀椀ned by their boundaries; therefore, domain tes琀椀ng
concentrates test points on or near boundaries.
o Classify what can go wrong with boundaries, then de昀椀ne a test strategy for each
case. Pick enough points to test for all recognized kinds of boundary errors.
o Because every boundary serves at least two di昀昀erent domains, test points used
to check one domain can also be used to check adjacent domains. Remove
redundant test points.
o Run the tests and by pos琀琀est analysis (the tedious part) determine if any

64

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

boundaries are faulty and if so, how.


o Run enough tests to verify every boundary of everydomain.

 DOMAIN BUGS AND HOW TO TEST FOR THEM:


o An interior point (Figure 4.10) is a point in the domain such that all points within
an arbitrarily small distance (called an epsilon neighborhood) are also in the
domain.
o A boundary point is one such that within an epsilon neighborhood there are
points both in the domain and not in the domain.
o An extreme point is a point that does not lie between any two other arbitrary
but dis琀椀nct points of a (convex) domain.

Figure 4.10: Interior, Boundary and Extreme points.


o An on point is a point on the boundary.
o If the domain boundary is closed, an o昀昀 point is a point near the boundary but in
the adjacent domain.
o If the boundary is open, an o昀昀 point is a point near the boundary but in the
domain being tested; see Figure 4.11. You can remember this by the acronym
COOOOI: Closed O昀昀 Outside, Open O昀昀 Inside.

Figure 4.11: On points and Off points.


o Figure 4.12 shows generic domain bugs: closure bug, shi昀琀ed boundaries, 琀椀lted
boundaries, extra boundary, missing boundary.
65

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 4.12: Generic Domain Bugs.

TESTING ONE DIMENSIONAL DOMAIN:

The closure can be wrong (i.e., assigned to the wrong domain) or the boundary (a point in this case) can be shi昀琀ed
one way or the other, we can be missing a boundary, or we can have an extra boundary.
1. Figure 4.13 shows possible domain bugs for a one-dimensional open domain
boundary.
2. In Figure 4.13a we assumed that the boundary was to be open for A. The bug
we're looking for is a closure error, which converts > to >= or < to <= (Figure
4.13b). One test (marked x) on the boundary point detects this bug because
processing for that point will go to domain A rather than B.
3. In Figure 4.13c we've su昀昀ered a boundary shi昀琀 to the le昀琀. The test point we used
for closure detects this bug because the bug forces the point from the B domain,
where it should be, to A processing. Note that we can't dis琀椀nguish between a
shi昀琀 and a closure error, but we do know that we have a bug.

66

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 4.13: One Dimensional Domain Bugs, Open Boundaries.


4. Figure 4.13d shows a shi昀琀 the other way. The on point doesn't tell us anything
because the boundary shi昀琀 doesn't change the fact that the test point will be
processed in B. To detect this shi昀琀 we need a point close to the boundary but
within A. The boundary is open, therefore by de昀椀ni琀椀on, the o昀昀 point is in A
(Open O昀昀 Inside).
5. The same open o昀昀 point also su昀케ces to detect a missing boundary because what
should have been processed in A is now processed in B.
6. To detect an extra boundary we have to look at two domain boundaries. In this
context an extra boundary means that A has been split in two. The two o昀昀 points
that we selected before (one for each boundary) does the job. If point C had
been a closed boundary, the on test point at C would do it.
7. For closed domains look at Figure 4.14. As for the open boundary, a test point on
the boundary detects the closure bug. The rest of the cases are similar to the
open boundary, except now the strategy requires o昀昀 points just outside the
domain.

67

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 4.14: One Dimensional Domain Bugs, Closed Boundaries.

 TESTING TWO DIMENSIONAL DOMAINS:

1. Figure 4.15 shows possible domain boundary bugs for a two-dimensional domain.
2. A and B are adjacent domains and the boundary is closed with respect to A,
which means that it is open with respect to B.

Figure 4.15: Two Dimensional Domain Bugs.


3. For Closed Boundaries:
Closure Bug: Figure 4.15a shows a faulty closure, such as might be caused by using a wrong operator (for example, x
>= k when x > k was intended, or vice
versa). The two on points detect this bug because those values will get B rather than A processing.

68

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

1. Shi昀琀ed Boundary: In Figure 4.15b the bug is a shi昀琀 up, which converts
part of domain B into A processing, denoted by A'. This result is caused by
an incorrect constant in a predicate, such as x + y >= 17 when x + y >= 7
was intended. The o昀昀 point (closed o昀昀 outside) catches this bug. Figure
4.15c shows a shi昀琀 down that is caught by the two on points.
2. Tilted Boundary: A 琀椀lted boundary occurs when coe昀케cients in the
boundary inequality are wrong. For example, 3x + 7y > 17 when 7x + 3y >
17 was intended. Figure 4.15d has a 琀椀lted boundary, which creates erroneous domain
segments A' and B'. In this example the bug is caught by the le昀琀 on point.

3. Extra Boundary: An extra boundary is created by an extra predicate. An


extra boundary will slice through many di昀昀erent domains and will
therefore cause many test failures for the same bug. The extra boundary
in Figure 4.15e is caught by two on points, and depending on which way
the extra boundary goes, possibly by the o昀昀 point also.
4. Missing Boundary: A missing boundary is created by leaving a boundary
predicate out. A missing boundary will merge di昀昀erent domains and will
cause many test failures although there is only one bug. A missing
boundary, shown in Figure 4.15f, is caught by the two on points because
the processing for A and B is the same - either A or B processing.

 PROCEDURE FOR TESTING: The procedure is conceptually is straight forward. It can be


done by hand for two dimensions and for a few domains and prac琀椀cally impossible for
more than two variables.
1 Iden琀椀fy input variables.
2 Iden琀椀fy variable which appear in domain de昀椀ning predicates, such as control
昀氀ow predicates.
3 Interpret all domain predicates in terms of input variables.
4 For p binary predicates, there are at most 2 p combina琀椀ons of TRUE-FALSE
values and therefore, at most 2p domains. Find the set of all non null
domains. The result is a boolean expression in the predicates consis琀椀ng a set
of AND terms joined by OR's. For example ABC+DEF+GHI...... Where the
capital le琀琀ers denote predicates. Each product term is a set of linear
inequality that de昀椀nes a domain or a part of a mul琀椀ply connected domains.
5 Solve these inequali琀椀es to 昀椀nd all the extreme points of each domain
using any of the linear programming methods.

DOMAIN AND INTERFACE TESTING

 INTRODUCTION:
o Recall that we de昀椀ned integra琀椀on tes琀椀ng as tes琀椀ng the correctness of the
interface between two otherwise correct components.

69

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

o Components A and B have been demonstrated to sa琀椀sfy their component tests,


and as part of the act of integra琀椀ng them we want to inves琀椀gate possible
inconsistencies across their interface.
o Interface between any two components is considered as a subrou琀椀ne call.
o We're looking for bugs in that "call" when we do interface tes琀椀ng.
o Let's assume that the call sequence is correct and that there are no type
incompa琀椀bili琀椀es.
o For a single variable, the domain span is the set of numbers between (and
including) the smallest value and the largest value. For every input variable we
want (at least): compa琀椀ble domain spans and compa琀椀ble closures (Compa琀椀ble
but need not be Equal).
 DOMAINS AND RANGE:
o The set of output values produced by a func琀椀on is called the range of the
func琀椀on, in contrast with the domain, which is the set of input values over which
the func琀椀on is de昀椀ned.
o For most tes琀椀ng, our aim has been to specify input values and to predict and/or
con昀椀rm output values that result from those inputs.
oInterface tes琀椀ng requires that we select the output values of the calling rou琀椀ne i.e.
caller's range must be compa琀椀ble with the called rou琀椀ne's domain.
o An interface test consists of exploring the correctness of the following
mappings: caller domain --> caller range (caller unit test)
caller range --> called domain (integra琀椀on test)
called domain --> called range (called unit test)

 CLOSURE COMPATIBILITY:
o Assume that the caller's range and the called domain spans the same numbers -
for example, 0 to 17.
o Figure 4.16 shows the four ways in which the caller's range closure and the
called's domain closure can agree.
o The thick line means closed and the thin line means open. Figure 4.16 shows the
four cases consis琀椀ng of domains that are closed both on top (17) and bo琀琀om (0),
open top and closed bo琀琀om, closed top and open bo琀琀om, and open top and
bo琀琀om.

Figure 4.16: Range / Domain Closure Compatibility.


o Figure 4.17 shows the twelve di昀昀erent ways the caller and the called can
70

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

disagree about closure. Not all of them are necessarily bugs. The four cases
in which a
caller boundary is open and the called is closed (marked with a "?") are probably not buggy. It means that the caller
will not supply such values but the called can accept them.

Figure 4.17: Equal-Span Range / Domain Compatibility Bugs.

 SPAN COMPATIBILITY:
o Figure 4.18 shows three possibly harmless span incompa琀椀bili琀椀es.

Figure 4.18: Harmless Range / Domain Span incompatibility bug


(Caller Span is smaller than Called).
o In all cases, the caller's range is a subset of the called's domain. That's not
necessarily a bug.
o The rou琀椀ne is used by many callers; some require values inside a range and some
don't. This kind of span incompa琀椀bility is a bug only if the caller expects the
called rou琀椀ne to validate the called number for the caller.
o Figure 4.19a shows the opposite situa琀椀on, in which the called rou琀椀ne's domain
has a smaller span than the caller expects. All of these examples are buggy.

71

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 4.19: Buggy Range / Domain Mismatches


o In Figure 4.19b the ranges and domains don't line up; hence good values are
rejected, bad values are accepted, and if the called rou琀椀ne isn't robust enough,
we have crashes.
o Figure 4.19c combines these no琀椀ons to show various ways we can have holes in
the domain: these are all probably buggy.

 INTERFACE RANGE / DOMAIN COMPATIBILITY TESTING:


o For interface tes琀椀ng, bugs are more likely to concern single variables rather than
peculiar combina琀椀ons of two or more variables.
o Test every input variable independently of other input variables to con昀椀rm
compa琀椀bility of the caller's range and the called rou琀椀ne's domain span and
closure of every domain de昀椀ned for that variable.
o There are two boundaries to test and it's a one-dimensional domain; therefore,
it requires one on and one o昀昀 point per boundary or a total of two on points and
two o昀昀 points for the domain - pick the o昀昀 points appropriate to the closure
(COOOOI).
o Start with the called rou琀椀ne's domains and generate test points in accordance to
the domain-tes琀椀ng strategy used for that rou琀椀ne in component tes琀椀ng.
o Unless you're a mathema琀椀cal whiz you won't be able to do this without tools for
more than one variable at a 琀椀me.

72

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

UNIT IV
PATHS, PATH PRODUCTS AND REGULAR EXPRESSIONS

Paths,Path products and Regular expressions:- path products &pathexpression,reduc琀椀on


procedure, applica琀椀ons, regular expressions & 昀氀ow anomaly detec琀椀on.
Logic Based Tes琀椀ng:-overview,decision tables,pathexpressions,kv charts, speci昀椀ca琀椀ons.

PATH PRODUCTS AND PATH EXPRESSION:

 MOTIVATION:
o Flow graphs are being an abstract representa琀椀on of programs.
o Any ques琀椀on about a program can be cast into an equivalent ques琀椀on about
an appropriate 昀氀owgraph.
o Most so昀琀ware development, tes琀椀ng and debugging tools use 昀氀ow graphs
analysis techniques.

 PATH PRODUCTS:
o Normally 昀氀ow graphs used to denote only control 昀氀ow connec琀椀vity.
o The simplest weight we can give to a link is a name.
o Using link names as weights, we then convert the graphical 昀氀ow graph into an
equivalent algebraic like expressions which denotes the set of all possible paths
from entry to exit for the 昀氀ow graph.
o Every link of a graph can be given a name.
o The link name will be denoted by lower case italic le琀琀ers In tracing a path or
path segment through a 昀氀ow graph, you traverse a succession of link
names.
o The name of the path or path segment that corresponds to those links is
expressed naturally by concatena琀椀ng those link names.
o For example, if you traverse links a,b,c and d along some path, the name for that
path segment is abcd. This path name is also called a path product. Figure 5.1
shows some examples:

73

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 5.1: Examples of paths.


 PATH EXPRESSION:
o Consider a pair of nodes in a graph and the set of paths between those node.
o Denote that set of paths by Upper case le琀琀er such as X,Y. From Figure 5.1c,
the members of the path set can be listed as follows:
ac, abc, abbc, abbbc, abbbbc.............
o Alterna琀椀vely, the same set of paths can be denoted by :
ac+abc+abbc+abbbc+abbbbc+...........
o The + sign is understood to mean "or" between the two nodes of interest,
paths ac, or abc, or abbc, and so on can be taken.
o Any expression that consists of path names and "OR"s and which denotes a set
of paths between two nodes is called a "Path Expression”.

 PATH PRODUCTS:
o The name of a path that consists of two successive path segments is
conveniently expressed by the concatena琀椀on or Path Product of the segment
names.
o For example, if X and Y are de昀椀ned as X=abcde,Y=fghij,then the
path corresponding to X followed by Y is denoted by
XY=abcdefghij
o Similarly,
YX=fghijabcde
aX=aabcde
Xa=abcdea
XaX=abcdeaabcde
o If X and Y represent sets of paths or path expressions, their product represents
the set of paths that can be obtained by following every element of X by any
element of Y in all possible ways. For example,
o X = abc + def + ghi

74

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

o Y = uvw + z
Then,
XY = abcuvw + defuvw + ghiuvw + abcz + defz + ghiz
o If a link or segment name is repeated, that fact is denoted by an
exponent. The exponent's value denotes the number of repe琀椀琀椀ons:
o a1 = a; a2 = aa; a3 = aaa; an = aaaa . . . n 琀椀mes.
Similarly, if X = abcde then

X1 = abcde
X2 = abcdeabcde = (abcde)2
X3 = abcdeabcdeabcde = (abcde)2abcde
= abcde(abcde)2 = (abcde)3
o The path product is not commuta琀椀ve (that is XY!=YX).
o The path product is Associa琀椀ve.
RULE 1: A(BC)=(AB)C=ABC
where A,B,C are path names, set of path names or path expressions.
o The zeroth power of a link name, path product, or path expression is also
needed for completeness. It is denoted by the numeral "1" and denotes the
"path" whose length is zero - that is, the path that doesn't have any links.
o a0 = 1
o X0 = 1

 PATH SUMS:
o The "+" sign was used to denote the fact that path names were part of the same
set of paths.
o The "PATH SUM" denotes paths in parallel between nodes.
o Links a and b in Figure 5.1a are parallel paths and are denoted by a + b. Similarly,
links c and d are parallel paths between the next two nodes and are denoted by
c + d.
o The set of all paths between nodes 1 and 2 can be thought of as a set of
parallel paths and denoted by eacf+eadf+ebcf+ebdf.
o If X and Y are sets of paths that lie between the same pair of nodes, then
X+Y denotes the UNION of those set of paths. For example, in Figure 5.2:

Figure 5.2: Examples of path sums.


The 昀椀rst set of parallel paths is denoted by X + Y + d and the second set by U + V
+ W + h + i + j. The set of all paths in this 昀氀owgraph is f(X + Y + d)g(U + V + W
+ h + i + j)k
o The path is a set union opera琀椀on, it is clearly Commuta琀椀ve and Associa琀椀ve.
o RULE 2: X+Y=Y+X
o RULE 3: (X+Y)+Z=X+(Y+Z)=X+Y+Z
75

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 DISTRIBUTIVE LAWS:
o The product and sum opera琀椀ons are distribu琀椀ve, and the ordinary rules of
mul琀椀plica琀椀on apply; that is
RULE 4: A(B+C)=AB+AC and (B+C)D=BD+CD
o Applying these rules to the below Figure 5.1a yields
o e(a+b)(c+d)f=e(ac+ad+bc+bd)f = eacf+eadf+ebcf+ebdf

 ABSORPTION RULE:
o If X and Y denote the same set of paths, then the union of these sets is
unchanged; consequently,
RULE 5: X+X=X (Absorp琀椀on Rule)
o If a set consists of paths names and a member of that set is added to it, the
"new" name, which is already in that set of names, contributes nothing and can
be ignored.
o For example,
o if X=a+aa+abc+abcd+def then
X+a = X+aa = X+abc = X+abcd = X+def = X
It follows that any arbitrary sum of iden琀椀cal path expressions reduces to the same path expression.
 LOOPS:
Loops can be understood as an in昀椀nite set of parallel paths. Say that the loop consists of a single link b.
then the set of all paths through that loop point is b0+b1+b2+b3+b4+b5+..............

Figure 5.3: Examples of path loops.


This poten琀椀ally in昀椀nite sum is denoted by b* for an individual link and by X*

Figure 5.4: Another example of path loops.


o The path expression for the above 昀椀gure is denoted by
the nota琀椀on: ab*c=ac+abc+abbc+abbbc+................
o Evidently,
aa*=a*a=a+ and XX*=X*X=X+
o It is more convenient to denote the fact that a loop cannot be taken more than
a certain, say n, number of 琀椀mes.
o A bar is used under the exponent to denote the fact as
follows: Xn = X0+X1+X2+X3+X4+X5+...................+Xn

RULES 6 - 16:
o The following rules can be derived from the previous rules:
76

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

o RULE 6: Xn + Xm = Xn if n>m
RULE 6: Xn + Xm = Xm if m>n
RULE 7: XnXm = Xn+m
RULE 8: XnX* = X*Xn = X* RULE 9: XnX+ = X+Xn = X+ RULE
10: X*X+ = X+X* = X+ RULE 11: 1 + 1 = 1
RULE 12: 1X = X1 = X
Following or preceding a set of paths by a path of zero length does not change the set.
RULE 13: 1n = 1n = 1* = 1+ = 1
No ma琀琀er how o昀琀en you traverse a path of zero length,It is a path of zero length. RULE 14: 1++1 = 1*=1
The null set of paths is denoted by the numeral 0. it obeys the following
rules:
RULE 15: X+0=0+X=X
RULE 16: 0X=X0=0
If you block the paths of a graph for or a昀琀 by a graph that has no paths , there won’t be any paths.
REDUCTION PROCEDURE:

 REDUCTION PROCEDURE ALGORITHM:


o This sec琀椀on presents a reduc琀椀on procedure for conver琀椀ng a 昀氀owgraph whose
links are labeled with names into a path expression that denotes the set of all
entry/exit paths in that 昀氀owgraph. The procedure is a node-by-node removal
algorithm.
o The steps in Reduc琀椀on Algorithm are as follows:
1. Combine all serial links by mul琀椀plying their path expressions.
2. Combine all parallel links by adding their path expressions.
3. Remove all self-loops (from any node to itself) by replacing them with a
link of the form X*, where X is the path expression of the link in that
loop.

STEPS 4 - 8 ARE IN THE ALGORIHTM'S LOOP:


4. Select any node for removal other than the ini琀椀al or 昀椀nal node. Replace it
with a set of equivalent links whose path expressions correspond to all
the ways you can form a product of the set of inlinks with the set of
outlinks of that node.
5. Combine any remaining serial links by mul琀椀plying their path expressions.
6. Combine all parallel links by adding their path expressions.
7. Remove all self-loops as in step 3.
8. Does the graph consist of a single link between the entry node and the
exit node? If yes, then the path expression for that link is a path
expression for the original 昀氀owgraph; otherwise, return to step 4.
o A 昀氀owgraph can have many equivalent path expressions between a given pair of
nodes; that is, there are many di昀昀erent ways to generate the set of all paths
between two nodes without a昀昀ec琀椀ng the content of that set.
o The appearance of the path expression depends, in general, on the order in
which nodes are removed.

 CROSS-TERM STEP (STEP 4):


77

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

o The cross - term step is the fundamental step of the reduc琀椀on algorithm.

78

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

o It removes a node, thereby reducing the number of nodes by one.


o Successive applica琀椀ons of this step eventually get you down to one entry and
one exit node. The following diagram shows the situa琀椀on at an arbitrary node
that has been selected for removal:

o From the above diagram, one can infer:


o (a + b)(c + d + e) = ac + ad + + ae + bc + bd + be

 LOOP REMOVAL OPERATIONS:


o There are two ways of looking at the loop-removal opera琀椀on:

o In the 昀椀rst way, we remove the self-loop and then mul琀椀ply all outgoing links
by Z*.
o In the second way, we split the node into two equivalent nodes, call them A and
A' and put in a link between them whose path expression is Z*. Then we remove
node A' using steps 4 and 5 to yield outgoing links whose path expressions are
Z*X and Z*Y.

 A REDUCTION PROCEDURE - EXAMPLE:


o Let us see by applying this algorithm to the following graph where we remove
several nodes in order; that is

Figure 5.5: Example Flowgraph for demonstrating reduction


procedure.

o Remove node 10 by applying step 4 and combine by step 5 to yield

79

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

o Remove node 9 by applying step4 and 5 to yield

o Remove node 7 by steps 4 and 5, as follows:

o Remove node 8 by steps 4 and 5, to obtain:

o PARALLEL TERM (STEP 6):


Removal of node 8 above led to a pair of parallel links between nodes 4 and 5. combine them to create
a path expression for an equivalent link whose path expression is c+gkh; that is

o LOOP TERM (STEP 7):


80

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Removing node 4 leads to a loop term. The graph has now been replaced with the following
equivalent simpler graph:

o Con琀椀nue the process by applying the loop-removal step as follows:

o Removing node 5 produces:

o Remove the loop at node 6 to yield:

o Remove node 3 to yield

o Removing the loop and then node 6 result in the following


expression:
a(bgjf)*b(c+gkh)d((ilhd)*imf(bjgf)*b(c+gkh)d)*(ilhd)*e

o You can prac琀椀ce by applying the algorithm on the following 昀氀owgraphs and
generate their respec琀椀ve path expressions:

81

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 5.6: Some graphs and their path expressions.


APPLICATIONS:
o The purpose of the node removal algorithm is to present one very
generalized concept- the path expression and way of ge琀�ng it.
o Every applica琀椀on follows this common pa琀琀ern:
1. Convert the program or graph into a path expression.
2. Iden琀椀fy a property of interest and derive an appropriate set of "arithme琀椀c"
rules that characterizes the property.
Replace the link names by the link weights for the property of interest. The path expression has now been
converted to an expression in some algebra, such as
1. Ordinary algebra, regular expressions, or boolean algebra. This
algebraic expression summarizes the property of interest over the set
of all paths.
2. Simplify or evaluate the resul琀椀ng "algebraic" expression to answer the
ques琀椀on you asked.

 HOW MANY PATHS IN A FLOW GRAPH ?


o The ques琀椀on is not simple. Here are some ways you could ask it:
1. What is the maximum number of di昀昀erent paths possible?
2. What is the fewest number of paths possible?
3. How many di昀昀erent paths are there really?
4. What is the average number of paths?
o Determining the actual number of di昀昀erent paths is an inherently di昀케cult
problem because there could be unachievable paths resul琀椀ng from correlated
82

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

and dependent predicates.


o If we know both of these numbers (maximum and minimum number of possible
paths) we have a good idea of how complete our tes琀椀ng is.
o Asking for "the average number of paths" is meaningless.

 MAXIMUM PATH COUNT ARITHMETIC:


o Label each link with a link weight that corresponds to the number of paths
that link represents.
o Also mark each loop with the maximum number of 琀椀mes that loop can be taken.
If the answer is in昀椀nite, you might as well stop the analysis because it is clear that
the maximum number of paths will be in昀椀nite.
o There are three cases of interest: parallel links, serial links, and loops.

o This arithme琀椀c is an ordinary algebra. The weight is the number of paths


in each set.
o EXAMPLE:
 The following is a reasonably well-structured program.

Each link represents a single link and consequently is given a weight of "1" to start. Let’s
say the outer loop will be taken exactly four 琀椀mes and inner Loop Can be taken zero or
three 琀椀mes Its path expression, with a li琀琀le work, is:
Path expression: a(b+c)d{e(昀椀)*fgj(m+l)k}*e(昀椀)*fgh
 A: The 昀氀ow graph should be annotated by replacing the link name
with the maximum of paths through that link (1) and also note the
number of 琀椀mes for looping.
 B: Combine the 昀椀rst pair of parallel loops outside the loop and
also the pair in the outer loop.
 C: Mul琀椀ply the things out and remove nodes to clear the clu琀琀er.

83

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

1. For the Inner Loop:


D:Calculate the total weight of inner loop, which can execute a min. of 0 琀椀mes and max.
of 3 琀椀mes. So, it inner loop can be evaluated as follows:

13 = 10 + 11 + 12 + 13 = 1 + 1 + 1 + 1 = 4
2. E: Mul琀椀ply the link weights inside the loop: 1 X 4 = 4
3. F: Evaluate the loop by mul琀椀plying the link wieghts: 2 X 4 = 8.
4. G: Simpifying the loop further results in the total maximum number
of paths in the 昀氀owgraph:

2 X 84 X 2 = 32,768.

84

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Alterna琀椀vely, you could have subs琀椀tuted a "1" for each link in the path expression and then simpli昀椀ed, as follows:

a(b+c)d{e(fi)*fgj(m+l)k}*e(fi)*fgh
= 1(1 + 1)1(1(1 x 1)31 x 1 x 1(1 + 1)1)41(1 x 1)31 x 1 x 1
= 2(131 x (2))413
= 2(4 x 2)4 x 4
= 2 x 84 x 4 = 32,768
This is the same result we got graphically.Actually, the outer loop should be taken exactly four 琀椀mes. That doesn't
mean it will be taken zero or four 琀椀mes. Consequently, there is a super昀氀uous "4" on the outlink in the last step.
Therefore the maximum number of di昀昀erent paths is 8192 rather than 32,768.

STRUCTURED FLOWGRAPH:
Structured code can be de昀椀ned in several di昀昀erent ways that do not involve ad-hoc rules such as not using
GOTOs.
A structured 昀氀owgraph is one that can be reduced to a single link by successive applica琀椀on of the
transforma琀椀ons of Figure 5.7.

Figure 5.7: Structured Flowgraph Transformations.

The node-by-node reduc琀椀on procedure can also be used as a test for structured code.Flow graphs that DO NOT
contain one or more of the graphs shown below (Figure 5.8) as subgraphs are structured.
1. Jumping into loops
2. Jumping out of loops
3. Branching into decisions
4. Branching out of decisions

85

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 5.8: Un-structured sub-graphs.


LOWER PATH COUNT ARITHMETIC:
A lower bound on the number of paths in a rou琀椀ne can be approximated for structured 昀氀ow graphs.
The arithme琀椀c is as follows:

The values of the weights are the number of members in a set of paths.
EXAMPLE:
 Applying the arithme琀椀c to the earlier example gives us the iden琀椀cal
steps unitl step 3 (C) as below:

86

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 From Step 4, the it would be di昀昀erent from the previous example:

 If you observe the original graph, it takes at least two paths to cover
and that it can be done in two paths.
 If you have fewer paths in your test plan than this minimum
you probably haven't covered. It's another check.

CALCULATING THE PROBABILITY:


Path selec琀椀on should be biased toward the low - rather than the high-probability paths.This raises an interes琀椀ng
ques琀椀on:
87

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

What is the probability of being at a certain point in a routine?

This ques琀椀on can be answered under suitable assump琀椀ons primarily that all probabili琀椀es involved are
independent, which is to say that all decisions are independent and uncorrelated. We use the same algorithm as
before: node-by-node removal of uninteres琀椀ng nodes.
Weights, Notations and Arithmetic:
 Probabili琀椀es can come into the act only at decisions (including decisions
associated with loops).
 Annotate each outlink with a weight equal to the probability of going in
that direc琀椀on.
 Evidently, the sum of the outlink probabili琀椀es must equal 1
 For a simple loop, if the loop will be taken a mean of N 琀椀mes, the
looping probability is N/(N + 1) and the probability of not looping is 1/(N
+ 1).
 A link that is not part of a decision node has a probability of 1.
 The arithme琀椀c rules are those of ordinary arithme琀椀c.

 In this table, in case of a loop, PA is the probability of the link leaving the
loop and PL is the probability of looping.
 The rules are those of ordinary probability theory.
1. If you can do something either from column A with a probability
of PA or from column B with a probability P B, then the probability
that you do either is PA + PB.
2. For the series case, if you must do both things, and their
probabili琀椀es are independent (as assumed), then the probability
that you do both is the product of their probabili琀椀es.
 For example, a loop node has a looping probability of P L and a probability
of not looping of PA, which is obviously equal to I - PL.

88

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 Following the above rule, all we've done is replace the outgoing
probability with 1 - so why the complicated rule? A昀琀er a few steps in
which you've removed nodes, combined parallel terms, removed loops
and the like, you might 昀椀nd something like this:

because PL + PA + PB + PC = 1, 1 - PL = PA + PB + PC, and

89

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

which is what we've postulated for any decision. In other words, division by 1 - P L
renormalizes the outlink probabili琀椀es so that their sum equals unity a昀琀er the loop is
removed.

EXAMPLE:
 Here is a complicated bit of logic. We want to know the
probability associated with cases A, B, and C.

 Let us do this in three parts, star琀椀ng with case A. Note that the sum of
the probabili琀椀es at each decision node is equal to 1. Start by throwing
away anything that isn't on the way to case A, and then apply the
reduc琀椀on procedure. To avoid clu琀琀er, we usually leave out probabili琀椀es
equal to 1.

CASE A:

90

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 Case B is simpler:

 Case C is similar and should yield a probability of 1 - 0.125 - 0.158


= 0.717:

 These checks. It's a good idea when doing this sort of thing to calculate all
the probabili琀椀es and to verify that the sum of the rou琀椀ne's exit
probabili琀椀es does equal 1.
 If it doesn't, then you've made calcula琀椀on error or, more likely, you've
le昀琀 out some bra How about path probabili琀椀es? That's easy. Just trace
the path of interest and mul琀椀ply the probabili琀椀es as you go.
 Alterna琀椀vely, write down the path name and do the indicated arithme琀椀c
opera琀椀on.

91

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 Say that a path consisted of links a, b, c, d, e, and the associated


probabili琀椀es were .2, .5, 1., .01, and I respec琀椀vely. Path
abcbcbcdeabddea would have a probability of 5 x 10-10.
 Long paths are usually improbable.

MEAN PROCESSING TIME OF A ROUTINE:


Given the execu琀椀on 琀椀me of all statements or instruc琀椀ons for every link in a 昀氀owgraph and the probability for
each direc琀椀on for all decisions are to 昀椀nd the mean processing 琀椀me for the rou琀椀ne as a whole.
The model has two weights associated with every link: the processing 琀椀me for that link, denoted by T, and the
probability of that link P.
The arithme琀椀c rules for calcula琀椀ng the mean 琀椀me:

EXAMPLE:
1. Start with the original 昀氀ow graph annotated with probabili琀椀es and processing 琀椀me.

2.Combine the parallel links of the outer loop. The result is just the mean of the
processing 琀椀mes for the links because there aren't any other links leaving the 昀椀rst
node. Also combine the pair of links at the beginning of the 昀氀ow graph.

3. Combine as many serial links as you can.

92

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

4. Use the cross-term step to eliminate a node and to create the inner self -
loop. 5.Finally, you can get the mean processing 琀椀me, by using the arithme琀椀c
rules as follows:

PUSH/POP, GET/RETURN:
This model can be used to answer several di昀昀erent ques琀椀ons that can turn up in debugging. It can also help
decide which test cases to design.
The ques琀椀on is:

Given a pair of complementary operations such as PUSH (the stack) and POP
(the stack), considering the set of all possible paths through the routine, what
is the net effect of the routine? PUSH or POP? How many times? Under what
conditions?
Here are some other examples of complementary opera琀椀ons to which this model applies: GET/RETURN a
resource block.
OPEN/CLOSE a 昀椀le.
START/STOP a device or process.

93

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

EXAMPLE 1 (PUSH / POP):


 Here is the Push/Pop Arithme琀椀c:

 The numeral 1 is used to indicate that nothing of interest


(neither PUSH nor POP) occurs on a given link.
 "H" denotes PUSH and "P" denotes POP. The opera琀椀ons are
commuta琀椀ve, associa琀椀ve, and distribu琀椀ve.

 Consider the following 昀氀ow graph:

P(P + 1)1{P(HH)n1HP1(P + H)1}n2P(HH)n1HPH


 Simplifying by using the arithme琀椀c tables,
= (P2 + P){P(HH)n1(P + H)}n1(HH)n1
= (P2 + P){H2n1(P2 + 1)}n2H2n1
 Below Table 5.9 shows several combina琀椀ons of values for the twolooping
terms - M1 is the number of 琀椀mes the inner loop will be taken and M2
the number of 琀椀mes the outer loop will be taken.

94

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 5.9: Result of the PUSH / POP Graph Analysis.


 These expressions state that the stack will be popped only if the inner
loop is not taken.
 The stack will be le昀琀 alone only if the inner loop is iterated once, but
it may also be pushed.
 For all other values of the inner loop, the stack will only be pushed.

EXAMPLE 2 (GET / RETURN):


 Exactly the same arithme琀椀c tables used for previous example are used
for GET / RETURN a bu昀昀er block or resource, or, in fact, for any pair of

95

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

complementary opera琀椀ons in which the total number of opera琀椀ons in either direc琀椀on


is cumula琀椀ve.
 The arithme琀椀c tables for GET/RETURN are:

"G" denotes GET and "R" denotes RETURN.


 Consider the following 昀氀owgraph:

 G(G + R)G(GR)*GGR*R
= G(G + R)G3R*R
= (G + R)G3R*
= (G4 + G2)R*
 This expression speci昀椀es the condi琀椀ons under which the resources will be
balanced on leaving the rou琀椀ne.
 If the upper branch is taken at the 昀椀rst decision, the second loop must
be taken four 琀椀mes.
 If the lower branch is taken at the 昀椀rst decision, the second loop must
be taken twice.
 For any other values, the rou琀椀ne will not balance. Therefore, the 昀椀rst
loop does not have to be instrumented to verify this behavior because its
impact should be nil.

LIMITATIONS AND SOLUTIONS:

o The main limita琀椀on to these applica琀椀ons is the problem of unachievable paths.


o The node-by-node reduc琀椀on procedure, and most graph-theory-based algorithms
work well when all paths are possible, but may provide misleading results when some
paths are unachievable.
o The approach to handling unachievable paths (for any applica琀椀on) is to par琀椀琀椀on
the graph into subgraphs so that all paths in each of the subgraphs are
achievable.
o The resul琀椀ng subgraphs may overlap, because one path may be common
to several di昀昀erent subgraphs.
o Each predicate's truth-func琀椀onal value poten琀椀ally splits the graph into two
subgraphs. For n predicates, there could be as many as 2n subgraphs.

96

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

REGULAR EXPRESSIONS AND FLOW ANOMALY DETECTION:

 THE PROBLEM:
o The generic 昀氀ow-anomaly detec琀椀on problem (note: not just data-昀氀ow
anomalies, but any 昀氀ow anomaly) is that of looking for a speci昀椀c sequence
of op琀椀ons considering all possible paths through a rou琀椀ne.
o Let the opera琀椀ons be SET and RESET, denoted by s and r respec琀椀vely, and we
want to know if there is a SET followed immediately a SET or a RESET
followed immediately by a RESET (an ss or an rr sequence).
o Some more applica琀椀on examples:
1. A 昀椀le can be opened (o), closed (c), read (r), or wri琀琀en (w). If the 昀椀le is
read or wri琀琀en to a昀琀er it's been closed, the sequence is nonsensical.
Therefore, cr and cw are anomalous. Similarly, if the 昀椀le is read before
it's been wri琀琀en, just a昀琀er opening, we may have a bug. Therefore, or
is also anomalous. Furthermore, oo and cc, though not actual bugs, are
a waste of 琀椀me and therefore should also be examined.
2. A tape transport can do a rewind (d), fast-forward (f), read (r), write (w),
stop (p), and skip (k). There are rules concerning the use of the transport;
for example, you cannot go from rewind to fast-forward without an
intervening stop or from rewind or fast-forward to read or write without
an intervening stop. The following sequences are anomalous: df, dr, dw,
fd, and fr. Does the 昀氀owgraph lead to anomalous sequences on any path?
If so, what sequences and under what circumstances?
3. The data-昀氀ow anomalies discussed in Unit 4 requires us to detect
the dd, dk, kk, and ku sequences. Are there paths with anomalous
data 昀氀ows?

 THE METHOD:
o Annotate each link in the graph with the appropriate operator or the
null operator 1.
o Simplify things to the extent possible, using the fact that a + a = a and 12 = 1.
o You now have a regular expression that denotes all the possible sequences
of operators in that graph. You can now examine that regular expression
for the sequences of interest.
o EXAMPLE: Let A, B, C, be nonempty sets of character sequences whose smallest
string is at least one character long. Let T be a two-character string of characters.
Then if T is a substring of (i.e., if T appears within) AB nC, then T will appear in
AB2C. (HUANG's Theorem)
As an example, let
o A = pp
B = srr
C = rp
T = ss
97

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

The theorem states that ss will appear in pp(srr)nrp if it appears in pp(srr)2rp.


o However, let

A = p + pp + ps
B = psr + ps(r + ps)
C = rp
T = P4

Is it obvious that there is a p4 sequence in ABnC? The theorem states that we have only to look at

(p + pp + ps)[psr + ps(r + ps)]2rp

Mul琀椀plying out the expression and simplifying shows that there is no p4


sequence.
o Incidentally, the above observa琀椀on is an informal proof of the wisdom of looping
twice discussed in Unit 2. Because data-昀氀ow anomalies are represented by two-
character sequences, it follows the above theorem that looping twice is what you
need to do to 昀椀nd such anomalies.

 LIMITATIONS:
o Huang's theorem can be easily generalized to cover sequences of greater length
than two characters. Beyond three characters, though, things get complex and
this method has probably reached its u琀椀litarian limit for manual applica琀椀on.
o There are some nice theorems for 昀椀nding sequences that occur at the beginnings
and ends of strings but no nice algorithms for 昀椀nding strings buried in an
expression.
o Sta琀椀c 昀氀ow analysis methods can't determine whether a path is or is not
achievable. Unless the 昀氀ow analysis includes symbolic execu琀椀on or similar
techniques, the impact of unachievable paths will not be included in the analysis.
The 昀氀ow-anomaly applica琀椀on, for example, doesn't tell us that there will be a 昀氀ow anomaly - it tells us
that if the path is achievable, then there will be a 昀氀ow anomaly. Such analy琀椀cal problems go away, of
course, if you take the trouble to design rou琀椀nes for which all paths are achievable.

98

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

UNIT IV(Part-II)
LOGIC BASED TESTING

OVERVIEW OF LOGIC BASED TESTING:

 INTRODUCTION:
o The func琀椀onal requirements of many programs can be speci昀椀ed by decision
tables, which provide a useful basis for program and test design.
o Consistency and completeness can be analyzed by using boolean algebra, which
can also be used as a basis for test design. Boolean algebra is trivialized by using
Karnaugh-Veitch charts.
o "Logic" is one of the most o昀琀en used words in programmers' vocabularies but
one of their least used techniques.
o Boolean algebra is to logic as arithme琀椀c is to mathema琀椀cs. Without it, the tester
or programmer is cut o昀昀 from many test and design techniques and tools that
incorporate those techniques.
o Logic has been, for several decades, the primary tool of hardware logic designers.
o Many test methods developed for hardware logic can be adapted to so昀琀ware
logic tes琀椀ng. Because hardware tes琀椀ng automa琀椀on is 10 to 15 years ahead of
so昀琀ware tes琀椀ng automa琀椀on, hardware tes琀椀ng methods and its associated
theory is a fer琀椀le ground for so昀琀ware tes琀椀ng methods.
o As programming and test techniques have improved, the bugs have shi昀琀ed
closer to the process front end, to requirements and their speci昀椀ca琀椀ons. These
bugs range from 8% to 30% of the total and because they're 昀椀rst-in and last-out,
they're the costliest of all.
o The trouble with speci昀椀ca琀椀ons is that they're hard to express.
o Boolean algebra (also known as the senten琀椀al calculus) is the most basic of all
logic systems.
o Higher-order logic systems are needed and used for formal speci昀椀ca琀椀ons.
o Much of logical analysis can be and is embedded in tools. But these tools
incorporate methods to simplify, transform, and check speci昀椀ca琀椀ons, and the
methods are to a large extent based on boolean algebra.

o KNOWLEDGE BASED SYSTEM:

 The knowledge-based system (also expert system, or "ar琀椀昀椀cial


intelligence" system) has become the programming construct of choice
for many applica琀椀ons that were once considered very di昀케cult.
 Knowledge-based systems incorporate knowledge from a knowledge
domain such as medicine, law, or civil engineering into a database. The
data can then be queried and interacted with to provide solu琀椀ons to
problems in that domain.
 One implementa琀椀on of knowledge-based systems is to incorporate the
expert's knowledge into a set of rules. The user can then provide data

99

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

and ask ques琀椀ons based on that data.


 The user's data is processed through the rule base to yield conclusions
(tenta琀椀ve or de昀椀nite) and requests for more data. The processing is done
by a program called the inference engine.
 Understanding knowledge-based systems and their valida琀椀on problems
requires an understanding of formal logic.
o Decision tables are extensively used in business data processing; Decision-table
preprocessors as extensions to COBOL are in common use; boolean algebra is
embedded in the implementa琀椀on of these processors.
o Although programmed tools are nice to have, most of the bene昀椀ts of boolean
algebra can be reaped by wholly manual means if you have the right conceptual
tool: the Karnaugh-Veitch diagram is that conceptual tool.

 DECISION TABLES:

 Figure 6.1 is a limited - entry decision table. It consists of four areas called the condi琀椀on
stub, the condi琀椀on entry, the ac琀椀on stub, and the ac琀椀on entry.
 Each column of the table is a rule that speci昀椀es the condi琀椀ons under which the ac琀椀ons
named in the ac琀椀on stub will take place.
 The condi琀椀on stub is a list of names of condi琀椀ons.

Figure 6.1 : Examples of Decision Table.


 A more general decision table can be as below:

100

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 6.2 : Another Examples of Decision Table.


 A rule speci昀椀es whether a condi琀椀on should or should not be met for the rule to be
sa琀椀s昀椀ed. "YES" means that the condi琀椀on must be met, "NO" means that the condi琀椀on
must not be met, and "I" means that the condi琀椀on plays no part in the rule, or it is
immaterial to that rule.
The ac琀椀on stub names the ac琀椀ons the rou琀椀ne will take or ini琀椀ate if the rule is sa琀椀s昀椀ed.
 If the ac琀椀on entry is "YES", the ac琀椀on will take place; if "NO", the ac琀椀on will not take
place.
The table in Figure 6.1 can be translated as follows:

Ac琀椀on 1 will take place if condi琀椀ons 1 and 2 are met and if condi琀椀ons 3 and 4 are not met (rule
1) or if condi琀椀ons 1, 3, and 4 are met (rule 2).
 "Condi琀椀on" is another word for predicate.
 Decision-table uses "condi琀椀on" and "sa琀椀s昀椀ed" or "met". Let us use "predicate" and
TRUE / FALSE.
 Now the above transla琀椀ons become:
1. Ac琀椀on 1 will be taken if predicates 1 and 2 are true and if predicates 3 and 4
are false (rule 1), or if predicates 1, 3, and 4 are true (rule 2).
2. Ac琀椀on 2 will be taken if the predicates are all false, (rule 3).
3. Ac琀椀on 3 will take place if predicate 1 is false and predicate 4 is true (rule 4).
 In addi琀椀on to the stated rules, we also need a Default Rule that speci昀椀es the default
ac琀椀on to be taken when all other rules fail. The default rules for Table in Figure 6.1 is
shown in Figure 6.3

Figure 6.3 : The default rules of Table in Figure 6.1

 DECISION-TABLE PROCESSORS:

o Decision tables can be automa琀椀cally translated into code and, as such, are a
higher-order language
o If the rule is sa琀椀s昀椀ed, the corresponding ac琀椀on takes place
o Otherwise, rule 2 is tried. This process con琀椀nues un琀椀l either a sa琀椀s昀椀ed rule
results in an ac琀椀on or no rule is sa琀椀s昀椀ed and the default ac琀椀on is taken
o Decision tables have become a useful tool in the programmers kit, in
business data processing.

101

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

DECISION-TABLES AS BASIS FOR TEST CASE DESIGN:

1. The speci昀椀ca琀椀on is given as a decision table or can be easily converted into one.
2. The order in which the predicates are evaluated does not a昀昀ect interpreta琀椀on of
the rules or the resul琀椀ng ac琀椀on - i.e., an arbitrary permuta琀椀on of the predicate
order will not, or should not, a昀昀ect which ac琀椀on takes place.
3. The order in which the rules are evaluated does not a昀昀ect the resul琀椀ng ac琀椀on -
i.e., an arbitrary permuta琀椀on of rules will not, or should not, a昀昀ect which ac琀椀on
takes place.
4. Once a rule is sa琀椀s昀椀ed and an ac琀椀on selected, no other rule need be examined.
5. If several ac琀椀ons can result from sa琀椀sfying a rule, the order in which the ac琀椀ons
are executed doesn't ma琀琀er.

DECISION-TABLES AND STRUCTURE:

o Decision tables can also be used to examine a program's structure.


o Figure 6.4 shows a program segment that consists of a decision tree.
o These decisions, in various combina琀椀ons, can lead to ac琀椀ons 1, 2, or 3.

Figure 6.4 : A Sample Program


o If the decision appears on a path, put in a YES or NO as appropriate. If the
decision does not appear on the path, put in an I, Rule 1 does not contain
decision C, therefore its entries are: YES, YES, I, YES.
o The corresponding decision table is shown in Table 6.1

102

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

RULE 1 RULE 2 RULE 3 RULE 4 RULE 5 RULE 6

CONDITION A
CONDITION B
CONDITION C YES YES YES NO I NO I NO I
CONDITION D YES I NO I YES I YES I NO NO
YES I NO YES NO

ACTION 1 YES YES NO NO NO NO


ACTION 2 NO NO YES YES YES NO
ACTION 3 NO NO NO NO NO YES

Table 6.1: Decision Table corresponding to Figure 6.4


As an example, expanding the immaterial cases results as below:

Table 6.2: Expansion of Table 6.1


o Similalrly, If we expand the immaterial cases for the above Table 6.1, it results
in Table 6.2 as below:
R1 RULE 2 R3 RULE 4 R5 R6
CONDITION A YY YYYY YY NNNN NN NN
CONDITION B YY NNNN YY YYNN NY YN
CONDITION C CONDITION YN NNYY YN YYYY NN NN
D YY YNNY NN NYYN YY NN
1. Sixteen cases are represented in Table 6.1, and no case appears twice.
2. Consequently, the 昀氀owgraph appears to be complete and consistent.
3. As a 昀椀rst check, before you look for all sixteen combina琀椀ons, count the
number of Y's and N's in each row. They should be equal. We can 昀椀nd the bug
that way.

 ANOTHER EXAMPLE - A TROUBLE SOME PROGRAM:

1. Consider the following speci昀椀ca琀椀on whose puta琀椀ve 昀氀owgraph is shown in


Figure 6.5:
1. If condi琀椀on A is met, do process A1 no ma琀琀er what other ac琀椀ons
are taken or what other condi琀椀ons are met.
103

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

2. If condi琀椀on B is met, do process A2 no ma琀琀er what other ac琀椀ons are


taken or what other condi琀椀ons are met.
3. If condi琀椀on C is met, do process A3 no ma琀琀er what other ac琀椀ons are
taken or what other condi琀椀ons are met.
4. If none of the condi琀椀ons is met, then do processes A1, A2, and A3.
5. When more than one process is done, process A1 must be done 昀椀rst,
then A2, and then A3. The only permissible cases are: (A1), (A2), (A3),
(A1,A3), (A2,A3) and (A1,A2,A3).
2. Figure 6.5 shows a sample program with a bug.

Figure 6.5 : A Troublesome Program


o The programmer tried to force all three processes to be executed for the
cases but forgot that the B and C predicates would be done again, thereby
bypassing processes A2 and A3.
o Table 6.3 shows the conversion of this 昀氀ow graph into a decision table a昀琀er
expansion.

Table 6.3: Decision Table for Figure 6.5

PATH EXPRESSIONS:
GENERAL:
o Logic-based tes琀椀ng is structural tes琀椀ng when it's applied to structure (e.g.,
control 昀氀ow graph of an implementa琀椀on); it's func琀椀onal tes琀椀ng when it's applied
to a speci昀椀ca琀椀on.
104

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

o In logic-based tes琀椀ng we focus on the truth values of control 昀氀ow predicates.


o A predicate is implemented as a process whose outcome is a truth-func琀椀onal
value.
o For our purpose, logic-based tes琀椀ng is restricted to binary predicates.
o We start by genera琀椀ng path expressions by path tracing as in Unit V, but this
琀椀me, our purpose is to convert the path expressions into boolean algebra, using
the predicates' truth values (e.g., A and ) as weights.

BOOLEAN ALGEBRA:
o STEPS:
1. Label each decision with an uppercase le琀琀er that represents the truth
value of the predicate. The YES or TRUE branch is labeled with a le琀琀er
(say A) and the NO or FALSE branch with the same le琀琀er overscored (say
).
2. The truth value of a path is the product of the individual labels.
Concatena琀椀on or products mean "AND". For example, the straight-
through path of Figure 6.5, which goes via nodes 3, 6, 7, 8, 10, 11, 12, and
2, has a truth value of ABC. The path via nodes 3, 6, 7, 9 and 2 has a value
of .
3. If two or more paths merge at a node, the fact is expressed by use of a
plus sign (+) which means "OR".

Figure 6.5: A Troublesome Program


o Using this conven琀椀on, the truth-func琀椀onal values for several of the nodes can be
expressed in terms of segments from previous nodes. Use the node name to
iden琀椀fy the point.

105

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

o There are only two numbers in boolean algebra: zero (0) and one (1). One means
"always true" and zero means "always false".
o RULES OF BOOLEAN ALGEBRA:
 Boolean algebra has three operators: X (AND), + (OR) and (NOT)
 X : meaning AND. Also called mul琀椀plica琀椀on. A statement such as AB (A X
B) means "A and B are both true". This symbol is usually le昀琀 out as in
ordinary algebra.
 + : meaning OR. "A + B" means "either A is true or B is true or both".
 meaning NOT. Also nega琀椀on or complementa琀椀on. This is read as either "not A" or
"A bar". The en琀椀re expression under the bar is negated.
 The following are the laws of boolean algebra:

In all of the above, a le琀琀er can represent a single sentence or an en琀椀re boolean algebra expression.
Individual le琀琀ers in a boolean algebra expression are called Literals (e.g. A,B) The product of
several literals is called a product term (e.g., ABC, DE).
An arbitrary boolean expression that has been mul琀椀plied out so that it consists of the sum of products (e.g., ABC +
DEF + GH) is said to be in sum-of-products form.
The result of simpli昀椀ca琀椀ons (using the rules above) is again in the sum of product form and each product term in such a
simpli昀椀ed version is called a prime implicant. For example, ABC + AB
+ DEF reduce by rule 20 to AB + DEF; that is, AB and DEF are prime implicants. The path
expressions of Figure 6.5 can now be simpli昀椀ed by applying the rules.
The following are the laws of boolean algebra:

106

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Similarly,

The devia琀椀on from the speci昀椀ca琀椀on is now clear. The func琀椀ons should have been:

Loops complicate things because we may have to solve a boolean equa琀椀on to determine what predicate value
combina琀椀ons lead to where.

KV CHARTS:

INTRODUCTION:
o If you had to deal with expressions in four, 昀椀ve, or six variables, you could get
bogged down in the algebra and make as many errors in designing test cases as
there are bugs in the rou琀椀ne you're tes琀椀ng.
o Karnaugh-Veitch chart reduces boolean algebraic manipula琀椀ons to graphical
trivia.
o Beyond six variables these diagrams get cumbersome and may not be e昀昀ec琀椀ve.
SINGLE VARIABLE:
o Figure 6.6 shows all the boolean func琀椀ons of a single variable and their
equivalent representa琀椀on as a KV chart.

107

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 6.6 : KV Charts for Functions of a Single Variable.


o The charts show all possible truth values that the variable A can have.
o A "1" means the variable’s value is "1" or TRUE. A "0" means that the variable's
value is 0 or FALSE.
o The entry in the box (0 or 1) speci昀椀es whether the func琀椀on that the
chart represents is true or false for that value of the variable.
o We usually do not explicitly put in 0 entries but specify only the condi琀椀ons
under which the func琀椀on is true.
TWO VARIABLES:
o Figure 6.7 shows eight of the sixteen possible func琀椀ons of two variables.

108

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 6.7: KV Charts for Functions of Two Variables.


o Each box corresponds to the combina琀椀on of values of the variables for the row
and column of that box.
o A pair may be adjacent either horizontally or ver琀椀cally but not diagonally.
o Any variable that changes in either the horizontal or ver琀椀cal direc琀椀on does
not appear in the expression.
o In the 昀椀昀琀h chart, the B variable changes from 0 to 1 going down the column, and
because the A variable's value for the column is 1, the chart is equivalent to a
simple A.
o Figure 6.8 shows the remaining eight func琀椀ons of two variables.

109

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 6.8: More Functions of Two Variables.


o The 昀椀rst chart has two 1's in it, but because they are not adjacent, each
must be taken separately.
o They are wri琀琀en using a plus sign.
o It is clear now why there are sixteen func琀椀ons of two variables.
o Each box in the KV chart corresponds to a combina琀椀on of the variables' values.
o That combina琀椀on might or might not be in the func琀椀on (i.e., the
box corresponding to that combina琀椀on might have a 1 or 0
entry).
o Since n variables lead to 2 n combina琀椀ons of 0 and 1 for the variables, and
each such combina琀椀on (box) can be 昀椀lled or not 昀椀lled, leading to 2 2n ways of
doing this.
o Consequently for one variable there are 221 = 4 func琀椀ons, 16 func琀椀ons of 2
variables, 256 func琀椀ons of 3 variables, 16,384 func琀椀ons of 4 variables, andso
110

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

on.

111

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

o Given two charts over the same variables, arranged the same way, their product
is the term by term product, their sum is the term by term sum, and the
nega琀椀on of a chart is go琀琀en by reversing all the 0 and 1 entries in the chart.

OR

THREE VARIABLES:
o KV charts for three variables are shown below.
o As before, each box represents an elementary term of three variables with a bar
appearing or not appearing according to whether the row-column heading for
that box is 0 or 1.
o A three-variable chart can have groupings of 1, 2, 4, and 8 boxes.
o A few examples will illustrate the principles:

112

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Figure 6.8: KV Charts for Functions of Three Variables.


o You'll no琀椀ce that there are several ways to circle the boxes into
maximum- sized covering groups.

113

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

UNIT-V
STATES, STATE GRAPHS, AND TRANSITION TESTING

State, State Graphs and Transi琀椀on tes琀椀ng:- state graphs, good & bad state graphs, state
tes琀椀ng, Testability 琀椀ps.
Graph Matrices and Applica琀椀on:-Mo琀椀va琀椀onal overview, matrix of graph, rela琀椀ons, power of
a matrix, node reduc琀椀on algorithm, building tools. ( Student should be given an exposure to a tool
like JMeter or Win-runner).

Introduction
The 昀椀nite state machine is as fundamental to so昀琀ware engineering as boolean algebra
to logic.
State tes琀椀ng strategies are based on the use of 昀椀nite state machine models for so昀琀ware
structure, so昀琀ware behavior, or speci昀椀ca琀椀ons of so昀琀ware behavior.
Finite state machines can also be implemented as table-driven so昀琀ware, in which case
they are a powerful design op琀椀on.
State Graphs
 A state is de昀椀ned as: “A combina琀椀on of circumstances or a琀琀ributes belonging for the
琀椀me being to a person or thing.”
For example, a moving automobile whose engine is running can have the following
states with respect to its transmission.
 Reverse gear
 Neutral gear
 First gear
 Second gear
 Third gear
 Fourth gear
State graph -
Example
 For example, a program that detects the character sequence “ZCZC” can be in
the following states.
Neither ZCZC nor any part of it has been detected.
 Z has been detected.
 ZC has been detected.
 ZCZ has been detected.
 ZCZC has been detected.

States are represented by Nodes. State are numbered or may iden琀椀昀椀ed by words or whatever else is convenient.
114

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Inputs and Transitions


Whatever is being modeled is subjected to inputs. As a result of those inputs, the state
changes, or is said to have made a Transi琀椀on.
Transi琀椀ons are denoted by links that join the states.

The input that causes the transi琀椀on are marked on the link; that is, the inputs are
link weights.
There is one out link from every state for every input.
 If several inputs in a state cause a transi琀椀on to the same subsequent state, instead of
drawing a bunch of parallel links we can abbreviate the nota琀椀on by lis琀椀ng the several
inputs as in: “input1, input2, input3………”.

Finite State Machine


A 昀椀nite state machine is an abstract device that can be represented by a state graph
having a 昀椀nite number of states and a 昀椀nite number of transi琀椀ons between states.
o Outputs
An output can be associated with any link.
 Out puts are denoted by le琀琀ers or words and are separated from inputs by a slash as
follows: “input/output”.
 As always, output denotes anything of interest that’s observable and is not restricted to
explicit outputs by devices.
Outputs are also link weights.
If every input associated with a transi琀椀on causes the same output, then denoted it as:
o “input1, input2, input3…........../output”
es
State tables
 Big state graphs are clu琀琀ered and hard to follow.
 It’s more convenient to represent the state graph as a table (the state table
or state transi琀椀on table) that speci昀椀es the states, the inputs, the transi琀椀ons
and the outputs.
 The following conven琀椀ons are used:
 Each row of the table corresponds to a state.
 Each column corresponds to an input condi琀椀on.
 The box at the intersec琀椀on of a row and a column speci昀椀es the next state
(the transi琀椀on) and the output, if any.
State Table-Example

115

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Time Versus Sequence


 State graphs don’t represent 琀椀me-they represent sequence.
A transi琀椀on might take microseconds or centuries;
A system could be in one state for milliseconds and another for years- the state graph
would be the same because it has no no琀椀on of 琀椀me.
Although the 昀椀nite state machines model can be elaborated to include no琀椀ons of 琀椀me
in addi琀椀on to sequence, such as 琀椀me Petri Nets.
o So昀琀ware implementa琀椀on
There is rarely a direct correspondence between programs and the behavior of a
process described as a state graph.
The state graph represents, the total behavior consis琀椀ng of the transport, the so昀琀ware,
the execu琀椀ve, the status returns, interrupts, and so on.
There is no simple correspondence between lines of code and states. The state table
forms the basis.

116

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Good State Graphs and Bad


What cons琀椀tutes a good or a bad state graph is to some extent biased by the kinds of
state graphs that are likely to be used in a so昀琀ware test design context.
Here are some principles for judging.
o The total number of states is equal to the product of the possibili琀椀es of
factors that make up the state.
o For every state and input there is exactly one transi琀椀on speci昀椀ed to exactly one,
possibly the same, state.
o For every transi琀椀on there is one output ac琀椀on speci昀椀ed. The output could
be trivial, but at least one output does something sensible.
o For every state there is a sequence of inputs that will drive the system back to
the same state.

Important graphs

State Bugs-Number of States


The number of states in a state graph is the number of states we choose to recognize or
model.

117

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

The state is directly or indirectly recorded as a combina琀椀on of values of variables that


appear in the data base.
For example, the state could be composed of the value of a counter whose possible
values ranged from 0 to 9, combined with the se琀�ng of two bit 昀氀ags, leading to a total
of 2*2*10=40 states.
The number of states can be computed as follows:
o Iden琀椀fy all the component factors of the state.
o Iden琀椀fy all the allowable values for each factor.
o The number of states is the product of the number of allowable values of all
the factors.
Before you do anything else, before you consider one test case, discuss the number of
states you think there are with the number of states the programmer thinks there are.
 There is no point in designing tests intended to check the system’s behavior in various
states if there’s no agreement on how many states there are.
o Impossible States
Some 琀椀mes some combina琀椀ons of factors may appear to be impossible.
 The discrepancy between the programmer’s state count and the tester’s state count is
o昀琀en due to a di昀昀erence of opinion concerning “impossible states”.
A robust piece of so昀琀ware will not ignore impossible states but will recognize them and
invoke an illogical condi琀椀on handler when they appear to have occurred.

Equivalent States
Two states are Equivalent if every sequence of inputs star琀椀ng from one state produces
exactly the same sequence of outputs when started from the other state. This no琀椀on
can also be extended to set of states.

Merging of Equivalent States

118

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Recognizing Equivalent States


Equivalent states can be recognized by the following procedures:
The rows corresponding to the two states are iden琀椀cal with respect to
input/output/next state but the name of the next state could di昀昀er.
There are two sets of rows which, except for the state names, have iden琀椀cal state
graphs with respect to transi琀椀ons and outputs. The two sets can be merged.

TransitionBugs-
unspeci昀椀ed and contradictory Transi琀椀ons
Every input-state combina琀椀on must have a speci昀椀ed transi琀椀on.
If the transi琀椀on is impossible, then there must be a mechanism that prevents the input
from occurring in that state.
Exactly one transi琀椀on must be speci昀椀ed for every combina琀椀on of input and state.
 A program can’t have contradic琀椀ons or ambigui琀椀es.
Ambigui琀椀es are impossible because the program will do something for every input. Even
the state does not change, by de昀椀ni琀椀on this is a transi琀椀on to the same state.

Unreachable States
An unreachable state is like unreachable code.
A state that no input sequence can reach.
An unreachable state is not impossible, just as unreachable code is not impossible
There may be transi琀椀ons from unreachable state to other states; there usually
because the state became unreachable as a result of incorrect transi琀椀on.
There are two possibili琀椀es for unreachable states:
o There is a bug; that is some transi琀椀ons are missing.
o The transi琀椀ons are there, but you don’t know about it.

Dead States
A dead state is a state that once entered cannot be le昀琀.
This is not necessarily a bug but it is suspicious.

The states, transi琀椀ons, and the inputs could be correct, there could be no dead or
unreachable states, but the output for the transi琀椀on could be incorrect.
Output ac琀椀ons must be veri昀椀ed independently of states and
transi琀椀ons. State Tes琀椀ng
Impact of Bugs
If a rou琀椀ne is speci昀椀ed as a state graph that has been veri昀椀ed as correct in all details.
Program code or table or a combina琀椀on of both must s琀椀ll be implemented.
A bug can manifest itself as one of the following symptoms:
Wrong number of states.
Wrong transi琀椀ons for a given state-input combina琀椀on.
Wrong output for a given transi琀椀on.
119

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Pairs of states or sets of states that are inadvertently made equivalent.


States or set of states that are split to create in equivalent duplicates.
States or sets of states that have become dead.
States or sets of states that have become unreachable.

Principles of State Testing


The strategy for state tes琀椀ng is analogous to that used for path tes琀椀ng 昀氀ow graphs.
 Just as it’s imprac琀椀cal to go through every possible path in a 昀氀ow graph, it’s
imprac琀椀cal to go through every path in a state graph.
The no琀椀on of coverage is iden琀椀cal to that used for 昀氀ow graphs.
 Even though more state tes琀椀ng is done as a single case in a grand tour, it’s imprac琀椀cal
to do it that way for several reasons.
In the early phases of tes琀椀ng, you will never complete the grand tour because of bugs.
Later, in maintenance, tes琀椀ng objec琀椀ves are understood, and only a few of the states
and transi琀椀ons have to be tested. A grand tour is waste of 琀椀me.
Theirs is no much history in a long test sequence and so much has happened that
veri昀椀ca琀椀on is di昀케cult.

Starting point of state testing


De昀椀ne a set of covering input sequences that get back to the ini琀椀al state when star琀椀ng
from the ini琀椀al state.
For each step in each input sequence, de昀椀ne the expected next state, the expected
transi琀椀on, and the expected output code.
A set of tests, then, consists of three sets of sequences:
o Input sequences
o Corresponding transi琀椀ons or next-state names
o Output sequences

Limitations and Extensions


State transi琀椀on coverage in a state graph model does not guarantee complete tes琀椀ng.
How de昀椀nes a hierarchy of paths and methods for combining paths to produce covers of
state graphs.
 The simplest is called a “0 switch” which corresponds to tes琀椀ng each
transi琀椀on individually.
 The next level consists of tes琀椀ng transi琀椀ons sequences consis琀椀ng of two transi琀椀ons
called “1 switches”.
 The maximum length switch is “n-1 switch” where there are n numbers of states.
o Situa琀椀ons at which state tes琀椀ng is useful
Any processing where the output is based on the occurrence of one or more sequences
of events, such as detec琀椀on of speci昀椀ed input sequences, sequen琀椀al format valida琀椀on,
parsing, and other situa琀椀ons in which the order of inputs is important.
Most protocols between systems, between humans and machines,
between components of a system.
120

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Device drivers such as for tapes and discs that have complicated retry and recovery
procedures if the ac琀椀on depends on the state.
Whenever a feature is directly and explicitly implemented as one or more state transi琀椀on tables.

UNIT-5 (PART-II) GRAPH MATRICES AND APPLICATIONS

Problem with Pictorial Graphs


Graphs were introduced as an abstrac琀椀on of so昀琀ware structure.
Whenever a graph is used as a model, sooner or later we trace paths through it- to 昀椀nd a set of
covering paths, a set of values that will sensi琀椀ze paths, the logic func琀椀on that controls the 昀氀ow,
the processing 琀椀me of the rou琀椀ne, the equa琀椀ons that de昀椀ne the domain, or whether a state is
reachable or not.
 Path is not easy, and it’s subject to error. You can miss a link here and there or cover some
links twice.
 One solu琀椀on to this problem is to represent the graph as a matrix and to use matrix opera琀椀ons
equivalent to path tracing. These methods are more methodical and mechanical and don’t
depend on your ability to see a path they are more reliable.

Tool Building
If you build test tools or want to know how they work, sooner or later you will be implemen琀椀ng
or inves琀椀ga琀椀ng analysis rou琀椀nes based on these methods.
It is hard to build algorithms over visual graphs so the proper琀椀es or graph matrices are
fundamental to tool building.

The Basic Algorithms


The basic tool kit consists of:
Matrix mul琀椀plica琀椀on, which is used to get the path expression from every node to every
other node.
A par琀椀琀椀oning algorithm for conver琀椀ng graphs with loops into loop free graphs or
equivalence classes.
A collapsing process which gets the path expression from any node to any other node.

The Matrix of a Graph


 A graph matrix is a square array with one row and one column for every node in the graph.
 Each row-column combina琀椀on corresponds to a rela琀椀on between the node corresponding
to the row and the node corresponding to thecolumn.
 The rela琀椀on for example, could be as simple as the link name, if there is a link between the
nodes.
Some of the things to be observed:
The size of the matrix equals the number of nodes.
There is a place to put every possible direct connec琀椀on or link between any and any other node.
The entry at a row and column intersec琀椀on is the link weight of the link that connects the two
nodes in that direc琀椀on.
A connec琀椀on from node i to j does not imply a connec琀椀on from node j to node i.
 If there are several links between two nodes, then the entry is a sum; the “+” sign
denotes parallel links as usual.

121

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

A simple weight
 A simplest weight we can use is to note that there is or isn’t a connec琀椀on. Let “1” mean
that there is a connec琀椀on and “0” mean that there isn’t.
 The arithme琀椀c rules are:
 1+1=1 1*1=1
 1+0=1 1*0=0
 0+0=0 0*0=0
 A matrix de昀椀ned like this is called connec琀椀on matrix.
Connection matrix
 The connec琀椀on matrix is obtained by replacing each entry with 1 if there is a link and 0 if there
isn’t.
 As usual we don’t write down 0 entries to reduce the clu琀琀er.

122

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Connection Matrix-continued
Each row of a matrix denotes the out links of the node corresponding to that row.
Each column denotes the in links corresponding to that node.
A branch is a node with more than one nonzero entry in its row.
A junc琀椀on is node with more than one nonzero entry in its column.
A self loop is an entry along the diagonal.

Cyclomatic Complexity
 The cycloma琀椀c complexity obtained by subtrac琀椀ng 1 from the total number of entries in each
row and ignoring rows with no entries, we obtain the equivalent number of decisions for each
row. Adding these values and then adding 1 to the sum yields the graph’s cycloma琀椀ccomplexity.

123

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

Relations
A rela琀椀on is a property that exists between two objects of interest.
For example,
 “Node a is connected to node b” or aRb where “R” means “is connected to”.
 “a>=b” or aRb where “R” means greater than or equal”.
A graph consists of set of abstract objects called nodes and a rela琀椀on R between the nodes.
If aRb, which is to say that a has the rela琀椀on R to b, it is denoted by a link from a to b.
For some rela琀椀ons we can associate proper琀椀es called as link weights.

Transitive Relations
A rela琀椀on is transi琀椀ve if aRb and bRc implies aRc.
Most rela琀椀ons used in tes琀椀ng are transi琀椀ve.
Examples of transi琀椀ve rela琀椀ons include: is connected to, is greater than or equal to, is less than
or equal to, is a rela琀椀ve of, is faster than, is slower than, takes more 琀椀me than, is a subset of,
includes, shadows, is the boss of.
Examples of intransi琀椀ve rela琀椀ons include: is acquainted with, is a friend of, is a neighbor of,
is lied to, has a du chain between.

Reflexive Relations
A rela琀椀on R is re昀氀exive if, for every a, aRa.
A re昀氀exive rela琀椀on is equivalent to a self loop at every node.
Examples of re昀氀exive rela琀椀ons include: equals, is acquainted with, is a rela琀椀ve of.
Examples of irre昀氀exive rela琀椀ons include: not equals, is a friend of, is on top of, is under.

Symmetric Relations
A rela琀椀on R is symmetric if for every a and b, aRb implies bRa.
A symmetric rela琀椀on mean that if there is a link from a to b then there is also a link from b to a.

124

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

A graph whose rela琀椀ons are not symmetric are called directed


graph. A graph over a symmetric rela琀椀on is called an undirected
graph.
The matrix of an undirected graph is symmetric (aij=aji) for all i,j)

Antisymmetric Relations
A rela琀椀on R is an琀椀symmetric if for every a and b, if aRb and bRa, then a=b, or they are the same
elements.
Examples of an琀椀symmetric rela琀椀ons: is greater than or equal to, is a subset of, 琀椀me.
Examples of nonan琀椀symmetric rela琀椀ons: is connected to, can be reached from, is greater than,
is a rela琀椀ve of, is a friend of

quivalence Relations
An equivalence rela琀椀on is a rela琀椀on that sa琀椀s昀椀es the re昀氀exive, transi琀椀ve, and symmetric
proper琀椀es.
Equality is the most familiar example of an equivalence rela琀椀on.
If a set of objects sa琀椀sfy an equivalence rela琀椀on, we say that they form an equivalence class
over that rela琀椀on.
The importance of equivalence classes and rela琀椀ons is that any member of the equivalence class
is, with respect to the rela琀椀on, equivalent to any other member of that class.
The idea behind par琀椀琀椀on tes琀椀ng strategies such as domain tes琀椀ng and path tes琀椀ng, is that we
can par琀椀琀椀on the input space into equivalence classes.
Tes琀椀ng any member of the equivalence class is as e昀昀ec琀椀ve as tes琀椀ng them all.

Partial Ordering Relations


A par琀椀al ordering rela琀椀on sa琀椀s昀椀es the re昀氀exive, transi琀椀ve, and an琀椀symmetric proper琀椀es.
Par琀椀al ordered graphs have several important proper琀椀es: they are loop free, there is at least
one maximum element, and there is at least one minimum element.

The Powers of a Matrix


 Each entry in the graph’s matrix expresses a rela琀椀on between the pair of nodes
that corresponds to that entry.
Squaring the matrix yields a new matrix that expresses the rela琀椀on between each pair of nodes
via one intermediate node under the assump琀椀on that the rela琀椀on is transi琀椀ve.
The square of the matrix represents all path segments two links long.
The third power represents all path segments three links long.
Matrix Powers and Products
Given a matrix whose entries are aij, the square of that matrix is obtained by replacing every

125

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

entry with

126

Downloaded by Janani Ramannachetty ([email protected])


lOMoARcPSD|28021796

 n
 aij=Σ aik akj
 k=1
more generally, given two matrices A and B with entries aik and bkj, respec琀椀vely, their
product is a new matrix C, whose entries are cij, where:
 n
 Cij=Σ aik bkj

k=1

Partitioning Algorithm
Consider any graph over a transi琀椀ve rela琀椀on. The graph may have loops.
We would like to par琀椀琀椀on the graph by grouping nodes in such a way that every loop is
contained within one group or another.
Such a graph is par琀椀ally ordered.
There are many used for an algorithm that does that:
We might want to embed the loops within a subrou琀椀ne so as to have a resul琀椀ng graph which
is loop free at the top level.
Many graphs with loops are easy to analyze if you know where to break theloops.
 While you and I can recognize loops, it’s much harder to program a tool to do it unless
you have a solid algorithm on which to base the tool.

Node Reduction Algorithm (General)


The matrix powers usually tell us more than we want to know about most graphs.
In the context of tes琀椀ng, we usually interested in establishing a rela琀椀on between two nodes-
typically the entry and exit nodes.
In a debugging context it is unlikely that we would want to know the path expression
between every node and every other node.
The advantage of matrix reduc琀椀on method is that it is more methodical than the graphical
method called as node by node removal algorithm.
1. Select a node for removal; replace the node by equivalent links that bypass that node and
add those links to the links they parallel.
2. Combine the parallel terms and simplify as you can.
3. Observe loop terms and adjust the out links of every node that had a self loop to account
for the e昀昀ect of the loop.
4. The result is a matrix whose size has been reduced by 1. Con琀椀nue un琀椀l only the two nodes of
interest exist.

127

Downloaded by Janani Ramannachetty ([email protected])

You might also like