STM Notes Unit1
STM Notes Unit1
Page |1
Unit I
Introduction
What is Testing?
Related terms : SQA, QC, Verification, Validation
Verification of functionality for conformation against given specifications
By execution of the software application
A Test
Passes:
Functionality OK.
Fails:
Application functionality NOK.
Bug/Defect/Fault: Deviation from expected functionality.
Its not always obvious.
Purpose of Testing
1. To Catch Bugs
Bugs are due to imperfect Communication among programmers
Specs, design, low level functionality
Statistics say: about 3 bugs / 100 statements
2. Productivity Related Reasons
Insufficient effort in QA => High Rejection Ratio =>
Higher Rework => Higher Net Costs
Statistics:
QA costs:
2% for consumer products
80% for critical software
Quality Productivity
3. Goals for testing
Primary goal of Testing: Bug Prevention
Bug prevented rework effort is saved
[bug reporting, debugging, correction,
retesting]
If it is not possible, Testing must reach its secondary goal of bud discovery.
Good test design & tests clear diagnosis easy bug correction
Test Design Thinking
From the specs, write test specs. First and then code.
Eliminates bugs at every stage of SDLC.
If this fails, testing is to detect the remaining bugs.
4. 5 Phases in testers thinking
Phase 0: says no difference between debugging & testing
Today, its a barrier to good testing & quality software.
Phase 1: says Testing is to show that the software works
A failed test shows software does not work, even if many tests pass.
Objective not achievable.
Phase 2: says Software does not work
One failed test proves that.
Tests are to be redesigned to test corrected software.
But we do not know when to stop testing.
Page |2
Dichotomies
division into two especially mutually exclusive or contradictory groups or entities
the dichotomy between theory and practice
Let us look at six of them:
1. Testing & Debugging
2. Functional Vs Structural Testing
3. Designer vs Tester
Page |3
Page |4
Examples:
Designer vs
For a given model of programs, Structural tests may be done first and later the Functional, Or
vice-versa. Choice depends on which seems to be the natural choice.
Both are useful, have limitations and target different kind of bugs. Functional tests can detect
all bugs in principle, but would take infinite amount of time. Structural tests are inherently
finite, but cannot detect all bugs.
The Art of Testing is how much allocation % for structural vs how much % for functional.
Tester
Completely separated in black box testing. Unit testing may be done by either.
Artistry of testing is to balance knowledge of design and its biases against ignorance &
inefficiencies.
Tests are more efficient if the designer, programmer & tester are independent in all of unit,
unit integration, component, component integration, system, formal system feature testing.
The extent to which test designer & programmer are separated or linked depends on testing
level and the context.
Programmer / Designer
Tester
Likely to be biased.
Page |5
3. A module (well defined discrete component of a system) consists of internal complexity &
interface complexity and has a size.
Modularity
Efficiency
Programming in SMALL
Vs programming in BIG
Impact on the development environment due to the volume of customer requirements
#
Small
B ig
Buyer
Vs Builder (customer vs developer organization)
Buyer & Builder being the same (organization) clouds accountability.
Separate them to make the accountability clear, even if they are in the same organization.
The accountability increases motivation for quality.
The roles of all parties involved are:
Builder:
Designs for & is accountable to the Buyer.
Buyer:
Pays for the system.
Hopes to get profits from the services to the User.
Page |6
User:
Ultimate beneficiary of the system.
Interests are guarded by the Tester.
Tester:
Dedicated to the destruction of the s/w (builder)
Tests s/w in the interests of User/Operator.
Operator:
Lives with:
Page |7
A model project is
A Well Run & Successful Project.
Combination of Glory and Catastrophe
All hardware & software (firmware, OS, linkage editor, loader, compiler, utilities,
libraries) required to make the program run.
Usually bugs do not result from the environment. (with established h/w & s/w)
Page |8
Formal procedures.
Input preparation, outcome prediction and observation, documentation of test,
execution & observation of outcome are subject to errors.
An unexpected test result may lead us to revise the test and test model.
6) Testing & Levels:
3 kinds of tests (with different objectives)
1) Unit & Component Testing
a. A unit is the smallest piece of software that can be compiled/assembled, linked, loaded
& put under the control of test harness / driver.
b. Unit testing - verifying the unit against the functional specs & also the implementation
against the design structure.
Page |9
e. Sequence of Testing:
Unit/Component tests for A, B. Integration tests for A & B. Component testing for
(A,B) component
3) System Testing
System is a big component.
Concerns issues & behaviors that can be tested at the level of entire or major part of the
integrated system.
Includes testing for performance, security, accountability, configuration sensitivity,
start up & recovery
After understanding a Project, Testing Model, now lets see finally,
Role of the Model of testing :
Used for the testing process until system behavior is correct or until the model is insufficient
(for testing).
Unexpected results may force a revision of the model.
Art of testing consists of creating, selecting, exploring and revising models.
The model should be able to express the program.
P a g e | 10
Consequences of Bugs
Consequences:
(how bugs may affect users)
These range from mild to catastrophic on a 10 point scale.
Mild
Aesthetic bug such as misspelled output or mal-aligned print-out.
Moderate
Outputs are misleading or redundant impacting performance.
Annoying
Systems behavior is dehumanizing for e.g. names are truncated/modified arbitrarily, bills for
$0.0 are sent.
Till the bugs are fixed operators must use unnatural command sequences to get proper
response.
Disturbing
Legitimate transactions refused.
For e.g. ATM machine may malfunction with ATM card / credit card.
Serious
Losing track of transactions & transaction events. Hence accountability is lost.
Very serious
System does another transaction instead of requested e.g. Credit another account, convert withdrawals
to deposits.
Extreme
Frequent & Arbitrary - not sporadic & unusual.
Intolerable
Long term unrecoverable corruption of the Data base.
(not easily discovered and may lead to system down.)
Catastrophic
System fails and shuts down.
Infectious
Corrupts other systems, even when it may not fail.
Assignment of severity
Assign flexible & relative rather than absolute values to the bug (types).
Number of bugs and their severity are factors in determining the quality quantitatively.
Organizations design & use quantitative, quality metrics based on the above.
Parts are weighted depending on environment, application, culture, correction cost, current SDLC
phase & other factors.
Nightmares
Define the nightmares that could arise from bugs for the context of the organization/application.
Quantified nightmares help calculate importance of bugs.
That helps in making a decision on when to stop testing & release the product.
When to stop Testing
1. List all nightmares in terms of the symptoms & reactions of the user to their consequences.
2. Convert the consequences of into a cost. There could be rework cost. (but if the scope extends to the
public, there could be the cost of lawsuits, lost business, nuclear reactor meltdowns.)
3. Order these from the costliest to the cheapest. Discard those with which you can live with.
4. Based on experience, measured data, intuition, and published statistics postulate the kind of bugs
causing each symptom. This is called bug design process. A bug type can cause multiple symptoms.
5. Order the causative bugs by decreasing probability (judged by intuition, experience, statistics etc.).
Calculate the importance of a bug type as:
P a g e | 11
all j
Taxonomy of Bugs
we had seen the:
1. Importance of Bugs - statistical quantification of impact
2. Consequences of Bugs - causes, nightmares, to stop testing
We will now see the:
3. Taxonomy of Bugs - along with some remedies
In order to be able to create an organizations own Bug Importance Model for the sake of controlling
associated costs
Why Taxonomy ?
To study the consequences, nightmares, probability, importance, impact and the methods of prevention
and correction.
Adopt known taxonomy to use it as a statistical framework on which your testing strategy is based.
6 main categories with sub-categories..
1. Requirements, Features, Functionality Bugs
24.3% bugs
2. Structural Bugs
25.2%
3. Data Bugs
22.3%
4. Coding Bugs
9.0%
5. Interface, Integration and System Bugs
10.7%
6. Testing & Test Design Bugs
2.8 %
1) Requirements, Features, Functionality Bugs
3 types of bugs : Requirement & Specs, Feature, & feature interaction bugs
I. Requirements & Specs.
These are expensive: introduced early in SDLC and removed at the last
II. Feature Bugs
P a g e | 12
Remedies
Testing Techniques
Functional test techniques - transaction flow testing, syntax testing, domain testing,
logic testing, and state testing - can eliminate requirements & specifications bugs.
2) Structural Bugs
we look at the 5 types, their causes and remedies.
I. Control & Sequence bugs
II. Logic Bugs
III. Processing bugs
IV. Initialization bugs
V.
Data flow bugs & anomalies
I.
Control & Sequence Bugs:
Paths left out, unreachable code, spaghetti code, and pachinko code.
Improper nesting of loops, Incorrect loop-termination or look-back, ill-conceived
switches.
Missing process steps, duplicated or unnecessary processing, rampaging GOTOs.
Novice programmers.
Old code (assembly language & Cobol)
Prevention and Control:
Theoretical treatment and,
Unit, structural, path, & functional testing.
II.
Logic Bugs
Misunderstanding of the semantics of the control structures & logic operators
Improper layout of cases, including impossible & ignoring necessary cases,
Using a look-alike operator, improper simplification, confusing Ex-OR with inclusive
OR.
Deeply nested conditional statements & using many logical operations in 1 stmt.
Prevention and Control:
Logic testing, careful checks, functional testing
III.
Processing Bugs
Arithmetic, algebraic, mathematical function evaluation, algorithm selection & general.
processing, data type conversion, ignoring overflow, improper use of relational
operators.
IV.
V.
P a g e | 13
Prevention
Caught in Unit Testing & have only localized effect
Domain testing methods
Initialization Bugs
Forgetting to initialize work space, registers, or data areas.
Wrong initial value of a loop control parameter.
Accepting a parameter without a validation check.
Initialize to wrong data type or format.
Very common.
Remedies (prevention & correction)
Programming tools, Explicit declaration & type checking in source language,
preprocessors.
Data flow test methods help design of tests and debugging.
Dataflow Bugs & Anomalies
Run into an un-initialized variable.
Not storing modified data.
Re-initialization without an intermediate use.
Detected mainly by execution (testing).
Remedies (prevention & correction)
Data flow testing methods & matrix based testing methods
3. Data Bugs
Depend on the types of data or the representation of data. There are 4 sub categories.
I. Generic Data Bugs
II. Dynamic Data Vs Static Data
III. Information, Parameter, and Control Bugs
IV. Contents, Structure & Attributes related Bugs
I. Generic Data Bugs
Due to data object specs., formats, # of objects & their initial values.
Generalized components with reusability when customized from a large parametric data to
specific installation.
Remedies (prevention & correction):
Using control tables in lieu of code facilitates software to handle many transaction types with
fewer data bugs. Control tables have a hidden programming language in the database.
Caution - theres no compiler for the hidden control language in data tables
II. Dynamic Data Vs Static Data
Dynamic Data Bugs
Transitory. Difficult to catch.
Due to an error in a shared storage object initialization. Appear in source code or data base, directly or
indirectly
Due to unclean / leftover garbage in a shared resource. Software to produce object code creates a static data
table bugs possible
Examples
Examples
Generic & shared variable
P a g e | 14
P a g e | 15
P a g e | 16
Path testing, transaction flow testing, data-flow testing & stress testing.
P a g e | 17
h) Integration Bugs:
Are detected late in the SDLC and cause several components and hence are very costly.
Due to:
Inconsistencies or incompatibilities between components.
Error in a method used to directly or indirectly transfer data between components. Some
communication methods are: data structures, call sequences, registers, semaphores,
communication links, protocols etc..
Remedies:
Employ good integration strategies.
Test Techniques
Those aimed at interfaces, domain testing, syntax testing, and data flow testing when applied
across components.
i) System Bugs:
Infrequent, but are costly
Due to:
Bugs not ascribed to a particular component, but result from the totality of interactions among
many components such as:
programs, data, hardware, & the O.S.
Remedies:
Thorough testing at all levels and the test techniques mentioned below
Test Techniques
Transaction-flow testing.
All kinds of tests at all levels as well as integration tests - are useful.
6. Testing & Test Design Bugs
Bugs in Testing (scripts or process) are not software bugs.
Its difficult & takes time to identify if a bug is from the software or from the test script/procedure.
1) Bugs could be due to:
Tests require code that uses complicated scenarios & databases, to be executed.
Though an independent functional testing provides an un-biased point of view, this lack of bias may lead to
an incorrect interpretation of the specs.
Test Criteria
Testing process is correct, but the criterion for judging softwares response to tests is incorrect or
impossible.
If a criterion is quantitative (throughput or processing time), the measurement test can perturb the
actual value.
Remedies:
i. Test Debugging:
Testing & Debugging tests, test scripts etc. Simpler when tests have localized affect.
ii. Test Quality Assurance:
To monitor quality in independent testing and test design.
iii. Test Execution Automation:
Test execution bugs are eliminated by test execution automation tools & not using manual testing.
iv. Test Design Automation:
Test design is automated like automation of software development.
For a given productivity rate, It reduces bug count.
P a g e | 18
Unit II
Flow graphs and Path testing
Basics: Path Testing Definition
A family of structural test techniques based on judiciously selecting a set of test paths
through the
programs.
Goal: Pick enough paths to assure that every source statement is executed at least once.
It is a measure of thoroughness of code coverage(During unit testing: # stmts executed at least once /
total # stmts).
It is used most for unit testing on new software.
Its effectiveness reduces as the software size increases.
We use Path testing techniques indirectly.
Path testing concepts are used in and along with other testing techniques
Assumptions
Observations
Structured programming languages need less of path testing.
Assembly language, Cobol, Fortran, Basic & similar languages make path testing necessary.
Process Block:
A sequence of program statements uninterrupted by decisions or junctions with a single entry and
single exit.
Junction:
A point in the program where control flow can merge (into a node of the graph)
Examples: target of GOTO, Jump, Continue
Decisions:
A program point at which the control flow can diverge (based on evaluation of a condition).
P a g e | 19
Examples: IF stmt.
Conditional branch and Jump instruction.
Case Statements:
A Multi-way branch or decision.
Examples: In assembly language: jump addresses table, Multiple GOTOs, Case/Switch
For test design, Case statement and decision are similar.
Control Flow Graph Vs Flow Charts
Control Flow Graph
Flow Chart
P a g e | 20
A process box is implied on every junction and decision, Remove External Labels, Represent the
contents of elements by numbers.
INPUT X, Y
Z := X + Y
V := X - Y
IF Z >= 0 GOTO SAM
JOE: Z := Z + V
SAM: Z := Z - V
FOR N = 0 TO V
Z := Z - 1
NEXT N
END
P a g e | 21
Merge all exits to Single-exit point after setting one exit parameter to a value.
P a g e | 22
1.
2.
3.
4.
g
Y
Y
P a g e | 23
P a g e | 24
P a g e | 25
P a g e | 26
Every selected path leads to an associated boolean expression, called the path predicate expression,
which characterizes the input values (if any) that will cause that path to be traversed.
Select an entry/exit path. Write down un-interpreted predicates for the decisions along the path. If
there are iterations, note also the value of loop-control variable for that pass. Converting these into
predicates that contain only input variables, we get a set of boolean expressions called path predicate
expression.
Example (inputs being numerical values):
If X 5 > 0 .OR. X 6 < 0 then
X1 + 3X2 + 17 >= 0
X3 = 17
X4 X1 >= 14 X2
A:
X5>0
E: X 6 < 0
B:
X1 + 3X2 + 17 >= 0
F: X1 + 3X2 + 17 >= 0
C:
X3 = 17
G: X3 = 17
D:
X4 X1 >= 14 X2
H: X4 X1 >= 14 X2
Converting into the predicate expression form:
ABCD+EBCD (A+E)BCD
If we take the alternative path for the expression: D then
(A + E ) B C D
Predicate Coverage:
Look at examples & possibility of bugs:
ABCD
A+B+C+D
Due to semantics of the evaluation of logic expressions in the languages, the entire expression
may not be always evaluated.
A bug may not be detected.
A wrong path may be taken if there is a bug.
Realize that on our achieving C2, the program could still hide some control flow bugs.
Predicate coverage:
If all possible combinations of truth values corresponding to selected path have been explored
under some test, we say predicate coverage has been achieved.
Stronger than branch coverage.
If all possible combinations of all predicates under all interpretations are covered, we have the
equivalent of total path testing.
Testing blindness
coming to the right path even thru a wrong decision (at a predicate). Due to the
interaction of some statements makes a buggy predicate work, and
the bug is not detected by the selected input values.
calculating wrong number of tests at a predicate
by ignoring the # of paths to arrive at it.
P a g e | 27
Self-blinding
When a buggy predicate is a multiple of the correct one and the result is indistinguishable
along that path.
Correct
Buggy
X := A
X := A
IF X - 1 > 0 THEN
IF X + A -2 > 0 THEN
(check for any X,A)
Achievable Paths
1. Objective is to select & test just enough paths to achieve a satisfactory notion of test completeness such as C1
+ C2.
2. Extract the programs control flow graph & select a set of tentative covering paths.
3. For a path in that set, interpret the predicates.
4. Trace the path through, multiplying the individual compound predicates to achieve a boolean expression.
Example: (A + BC) ( D + E)
5. Multiply & obtain sum-of-products form of the path predicate expression:
AD + AE + BCD + BCE
6. Each product term denotes a set of inequalities that, if solved, will yield an input vector that will drive the
routine along the selected path.
7. A set of input values for that path is found when any of the inequality sets is solved.
A solution found => path is achievable. Otherwise the path is unachievable.
Path Sensitization
Its the act of finding a set of solutions to the path predicate expression.
In practice, for a selected path finding the required input vector is not difficult. If there is difficulty, it may be
due to some bugs.
Heuristic procedures:
Choose an easily sensitizable path set, & pick hard-to-sensitize paths to achieve more coverage.
Identify all the variables that affect the decisions. For process dependent variables, express the nature of the
process dependency as an equation, function, or whatever is convenient and clear. For correlated variables,
express the logical, arithmetic, or functional relation defining the correlation.
1. Identify correlated predicates and document the nature of the correlation as for variables. If the same predicate
appears at more than one decision, the decisions are obviously correlated.
2. Start path selection with uncorrelated & independent predicates. If coverage is achieved, but the path had
dependent predicates, something is wrong.
3. If the coverage is not achieved yet with independent uncorrelated predicates, extend the path set by using
correlated predicates; preferably process independent (not needing interpretation)
4. If the coverage is not achieved, extend the path set by using dependent predicates (typically required to cover
loops), preferably uncorrelated.
5. Last, use correlated and dependent predicates.
6. For each of the path selected above, list the corresponding input variables. If the variable is independent, list
its value. For dependent variables, interpret the predicate ie., list the relation. For correlated variables, state the
nature of the correlation to other variables. Determine the mechanism (relation) to express the forbidden
combinations of variable values, if any.
7. Each selected path yields a set of inequalities, which must be simultaneously satisfied to force the path.
P a g e | 28
3. Dependent Predicates
Usually most of the processing does not affect the control flow.
Use computer simulation for sensitization in a simplified way.
Dependent predicates contain iterative loop statements usually.
For Loop statements:
Determine the value of loop control variable for a certain # of iterations, and then
work backward to determine the value of input variables (input vector).
4. The General Case
No simple procedure to solve for values of input vector for a selected path.
1. Select cases to provide coverage on the basis of functionally sensible paths.
Well structured routines allow easy sensitization.
Intractable paths may have a bug.
2. Tackle the path with the fewest decisions first. Select paths with least # of loops
3. Start at the end of the path and list the predicates while tracing the path in reverse.
Each predicate imposes restrictions on the subsequent (in reverse order) predicate.
4. Continue tracing along the path. Pick the broadest range of values for variables affected
and consistent with values that were so far determined.
5. Continue until the entrance & therefore have established a set of input conditions for the path.
P a g e | 29
Path Instrumentation
Output of a test:
Results observed. But, there may not be any expected output for a test.
Outcome:
Any change or the lack of change at the output.
Expected Outcome:
Any expected change or the lack of change at the output (predicted as part of design).
Actual Outcome:
Observed outcome
Coincidental Correctness:
When expected & actual outcomes match,
Necessary conditions for test to pass are met.
Conditions met are probably not sufficient.
(the expected outcome may be achieved due to a wrong reason)
Path Instrumentation is what we have to do confirm that the outcome was achieved by the intended path.
Path Instrumentation Methods
1. General strategy:
1. Based on Interpretive tracing & use interpreting trace program.
2. A trace confirms the expected outcome is or isnt obtained along the intended path.
3. Computer trace may be too massive. Hand tracing may be simpler.
2. Traversal or Link Makers:
Simple and effective
1. Name every link.
2. Instrument the links so that the link is recorded when it is executed (during the test)
3. The succession of letters from a routines entry to exit corresponds to the pathname
P a g e | 30
Sample path:
ijn
Single Link Marker Instrumentation: Not good enough
Problem:
Processing in the links may be chewed open by bugs. Possibly due to GOTO statements, control takes a
different path, yet resulting in the intended path again.
Double Link Marker Instrumentation:
P a g e | 31
P a g e | 32
P a g e | 33
Unit III
Transaction Flow Testing
Transaction-flow
Transaction-flow represents a systems processing. Functional testing methods are applied for testing T-F.
Transaction-flow Graph
TFG represents a behavioral (functional) model of the program (system) used for functional testing by an
independent system tester.
Transaction
is a unit of work seen from systems user point of view.
consists of a sequence of operations performed by a system, persons or external devices.
is created (birth) due to an external act & up on its completion (closure), it remains in the form of
historical records.
Example: the sequence of steps in a transaction in an online information retrieval system
1. accept inputs
7. Accept Inputs
2. Validate inputs (Birth of tr.)
8. Validate inputs
3. Transmit ack. to the user
9. Process the request
4. Process input
10. Update file
5. Search file
11. Transmit output
6. Request direction from user
12. Record transaction in log & cleanup (Closure)
Users View of a transaction
: Single step
Systems view
: Sequence of many operations
User (terminal)
Terminal controller
CPU
Example:
P a g e | 34
Definitions
Transaction-flow Graph : a scenario between users & computer
Transaction-flow
: an internal sequence of events in processing a transaction
Uses of Transaction-flow
Specifying requirements of big, online and complicated systems.
Airline reservation systems, air-traffic control systems.
Loops are less as compared to CFG. Loops are used for user input error processing
P a g e | 35
A perspective of Transaction-Flow
Transaction-flow testing is a block box technique. (as we assumed nothing regarding computer, communications,
environment, O.S., transaction identity or structure or state.)
1. TFG is a kind of DFG.
TFG has tokens, & DFG has data objects with history of operations applied on them.
Many techniques of CFG apply to TFG & DFG
2. Decision nodes of TFG have exception exits to the central recovery process.
3. So, we ignore the effect of interrupts in a Transaction-flow.
2. Biosis
3. Mitosis
Mergers of transactions
1. Junction
2. Absorption
P a g e | 36
3. Conjugation
Transaction-flow Structure
Reasons for Unstructuredness
1. Processes involve Human Users
2. Part of Flow from External Systems
3. Errors, Failures, Malfunctions & Recovery Actions
4. Transaction Count, Complexity. Customer & Environment
5. New Transactions, & Modifications
6. Approximation to Reality
7. Attempt to Structure
P a g e | 37
3. Sensitization
Functionally Sensible Paths Simple
Error, Exception, External Protocol Interface Paths - Difficult
Testing Tr.Flows with External Interfaces
Use patches & break points, mistune, and break the rules,
4. Instrumentation
Link Counters are not Useful.
Need
Trace
Queues on which Tokens resided
Entries to & Exits from Dispatcher
A Running Log
Make Instrumentation as part of System Design
5. Test Data bases
Design & Maintenance of a Test Data base - Effort
Mistakes
Unawareness about design of a centrally administered test DB
Test DB design by Testers
Using one DB for all tests (need 4 to 5)
Need experienced System & Test Designers
6. Test Execution
Use Test Execution Automation
Have to do a large # of Tests for C1+C2 coverage
Motivation
P a g e | 38
e := c * d
Multiple representations of control flow graphs possible.
Program Flow using Data Flow Machines paradigm
BEGIN
PAR DO
READ m, n, n, p, q
END PAR
PAR DO
a := m+n
b := p+q
END PAR
PAR DO
c := a+b
d := a-b
END PAR
PAR DO
e := c * d
END PAR
END
Control flow graph
Multiple representations
Data Flow Graph
A spec. for relations among the data objects. Covering DFG => Explore all relations under some test.
Assumptions
Problems in a control flow
Problems with data objects
Data Flow Graphs (DFG)
It is a graph with nodes & directed links
Test the Von Neumann way Convert to a CFG
Annotate : program actions (weights)
Data Object State & Usage
Program Actions (d, k, u):
Defined (created)
explicitly or implicitly
(d)
Killed (released)
directly or indirectly
(k)
Used
(u)
o In a calculation
(c)
o In a predicate
directly or indirectly (p)
Data Flow Anomalies
A Two letter sequence of Actions (d, k, u)
dd
harmless, suspicious
dk
du
:
:
probably a bug.
normal
kd
kk
ku
:
:
:
normal
harmless, but probably a bug
a bug
P a g e | 39
:
normal.
Redefinition.
:
normal
:
normal
data objects
no action from START to this point
From this point till the EXIT
normal
anomaly
anomaly
k-
normal
u-
normal
possibly an anomaly
dpossibly anomalous
Data Flow Anomaly State graph
Data Object State
K, D, U, A
Processing Step
k, d, u
Data Flow Anomaly State graph
Object state
Unforgiving Data
flow state graph
P a g e | 40
P a g e | 41
P a g e | 42
Definitions
w.r.t. a variable or data object v
Assume all DF paths are achievable
1. Definition-clear path segment
no k, kd
Loop-free path segment
Simple path segment
du path from node i to k
definition-clear & simple
c
definition-clear & loop-free
p
DFT Strategies
All-du paths (ADUP)
All uses (AU) strategy
All p-uses/some c-uses and All c-uses/some p-uses
All Definitions Strategy
All p-uses, All c-uses Strategy
Purpose
Test Design, Develop Test Cases
1. All-du paths (ADUP)
Strongest DFT
Every du path for every variable for every definition to every use
2. All uses (AU) strategy
At least one definition clear path segment from every definition of every variable to every use of that
definition be exercised under some test.
At least one path segment from every definition to every use that can be reached from that definition.
P a g e | 43
P a g e | 44
Application of DFT
Comparison Random Testing, P2, AU - by Ntafos
AU detects more bugs than
P2 with more test cases
RT with less # of test cases
Comparison of P2, AU - by Sneed
AU detects more bugs with 90% Data Coverage Requirement.
Comparison of # test cases for ACU, APU, AU & ADUP by Weyuker using ASSET testing system
Test Cases Normalized. t = a + b * d
d = # binary decisions
At most d+1 Test Cases for P2
loop-free
# Test Cases / Decision
ADUP > AU > APU > ACU > revised-APU
Comparison of # test cases for ACU, APU, AU & ADUP by Shimeall & Levenson
Test Cases Normalized. t = a + b * d
(d = # binary decisions)
At most d+1 Test Cases for P2
loop-free
# Test Cases / Decision
ADUP ~ APU*
AP ~ AC
DFT vs P1, P2
DFT is Effective
Effort for Covering Path Set ~ Same
DFT Tracks the Coverage of Variables
Test Design is similar
DFT
TOOLS
Cost-effective development
Commercial tools :
Can possibly do Better than Commercial Tools
Easier Integration into a Compiler
Efficient Testing
P a g e | 45
Unit - IV
Domain Testing
Domains and Paths:
Domain Testing
Views Programs as input data classifiers
Verifies if the classification is correct
Domain Testing Model
Domain
A Single Connected Set of numbers
No arbitrary discrete sets
Defined by the boundaries
One or more boundaries
Specified by predicates
Bugs likely at the boundaries
One or more variables
Predicates
Interpretation
Structural Testing - CFG
Functional Testing - DFG
Specifies the Domain Boundary
n Predicates in Sequence 2n domains
Or, just two domains
A .AND. B .AND. C
P a g e | 46
Paths
At least One PATH thru the Program
More paths for disconnected domains
Points to remember
Domain for a loop-free program corresponds to a set of numbers defined over the input vector
For every domain, there is at least one path thru the routine, along which that domains processing is done
The set of interpreted predicates traversed on that path (ie., the paths predicate expression) defines the
domains boundaries.
Domain Closure
Boundary: Closed / Open
Domain Dimensionality
One dimension per variable
At least one predicate
Slices thru previously defined Domain
Slicing Boundary
N-spaces are cut by Hyperplanes
Bug Assumptions
Processing is OK. Domain definition may be wrong.
Boundaries are wrong.
Predicates are wrong.
Once input vector is set on the right path, its correctly processed.
More bugs causing domain errors
Double-zero representation
Ambiguous domains
Floating point zero check
Contradictory domains
P a g e | 47
Over-specified domains
X > 3 .AND. X < 2 .AND. Y > 3
Boundary errors
Boundary closure
Shifted
Boundary errors.
Tilted
Missing
Extra boundary
Closure Reversal
Faulty Logic
Simplification of compound predicates
Restrictions
1. Coincidental Correctness
DT cannot detect
Example
Representative outcome
Partition testing
Input Equivalence
2. Simple boundaries & Compound predicates
P a g e | 48
Compound predicates
Impact of .OR.
Concave, Disconnected
Adjacent domains with same function
Example
ABC + DEF
Eliminate compound predicates
3. Functional Homogeneity of Bugs
Functional form still Retained
a x + b y >= c
Bugs are only in a, b, c
4. Linear Vector Space
Linear boundary predicate, Interpreted
Simple relational operators
Conversion to linear vector space
2-d Polar co-ordinates
Polynomials
Problems with Non-linear Boundaries
5. Loop-free Software
Predicate for each iteration
Loop over the entire transaction
Definite loop
Nice Domains
Requirements
Bugs ill-defined domains
Before DT
Analyze specs
Make the Boundary Specs Consistent & Complete
Implemented Domains
Complete, Consistent & Process all inputs
Specified Domains
Incomplete, Inconsistent
Programmers / Designers Effort
Nice Domains
Linear, Complete, Systematic, Orthogonal, Consistently Closed, & Convex
Advantages
Ease of DT
Fewer Bug Occurrences
P a g e | 49
Boundaries are
1. Linear
2. Complete
3. Systematic
4. Orthogonal
1. Linear Boundaries
Interpreted linear inequalities
n-dim Hyperplane:
n+1 Points
n+1 + 1 Test Cases
5. Closure consistency
6. Convex
7. Simply connected
Non-Linear
Transform
2. Complete Boundaries
Span the total number space
(-, +)
One set of Tests
Incomplete
Reasons
Tests
3. Systematic Boundaries
Linear Inequalities differing by a constant
fj (X) kj
or,
fj (X) g (j, c)
g (j, c) = j + k * c
Parallel lines
DT
Test a domain
4. Orthogonal Boundaries
Two boundaries or, boundary sets
Parallel to axes
DT
Each Set Independently
# Tests O (n)
Orthogonal Boundaries
Tilted sets
transformation
Test cases: O(n)
Concentric circles with radial lines
Rectangular coordinates
Polar
r aj .AND. r < aj+1 .AND.
P a g e | 50
5. Closure Consistency
A Simple pattern in all boundary closures
Example
Same relational operator for systematic boundaries
6. Convex Domain
Line joining any two points lies with in the domain
DT
n on-points & 1 off-pt
Concave
But, However, Except, Or in Specs
Handle with special care
7. Simply Connected Domain
In a single piece
2 complementary domains
D1: Convex
Programmer / Designer
Convex part First
Ugly Domains
Generally
From Bad Specs
Programmer / Designer Simplifies => Ugly to Good
possibility of Introduction of more bugs ?!?
Causes
1.
2.
3.
4.
Non-linear Boundaries
Ambiguities & Contradictions
Simplifying the topology
Rectifying boundary closures
P a g e | 51
1. Non-linear Boundaries
Transform
2. Ambiguities
Holes in input vector space.
Missing boundary
Detected by Specification languages & tools.
Contradictions..
Overlapping of
Filling in Holes
P a g e | 52
Correct:
Connect disconnected boundary segments
Extend boundaries to infinity
4. Rectifying Boundary Closures.
make closures in one direction for parallel boundaries with closures in both directions
Force a Bounding Hyperplane to belong to the Domain.
General DT Strategy
Select test points near the boundaries.
Define test strategy for each possible bug related to boundary
Test points for a domain useful to test its adjacent domain.
Run the tests. By post test analysis determine if any boundaries are faulty & if so how?
Run enough tests to verify every boundary of every domain
DT for Specific Domain Bugs
Generally,
Interior point
Exterior point
Epsilon neighborhood
Extreme point
On point
P a g e | 53
1-d Domains
2-d Domains
Equality & inequality Predicates
Random Testing
Testing n-dimensional Domains
Closure Bug
Missing Boundary
Extra Boundary
P a g e | 54
4. Random Testing
A Point in the center : verifies computation
P a g e | 55
Effectiveness
Cost effective
Bugs on boundaries, extreme points
Hardware logic testing tool intensive
Domains & Interface Testing
Domain
Range
Span compatibility
P a g e | 56
Unit V
Paths, Path products and Regular expressions
Path Products & expressions
Motivation:
Flow graph is an abstract representation of a program.
A question on a program can be mapped on to an equivalent question on an appropriate flow graph.
It will be a foundation for syntax testing & state testing
Path Expression
An algebraic representation of sets of paths in a flow graph.
Regular Expression
Path expressions converted by using arithmetic laws & weights into an algebraic function.
Annotate each link with a name.
The pathname as you traverse a path (segment) expressed as concatenation of the link names is the path
product.
Example
1. { a b d, a b c b d, a b c b c b d , .. }
abd + abcbd + abcbcbd + .
2.
P a g e | 57
X + Y = Y + X
: Rule 2
Associative
(X+Y)+Z = X+(Y+Z) = X+Y+Z
: Rule 3
Distributive
A ( B + C) = A B + A C
: Rule 4
(A+B)C = AC+BC
Absorption
X + X = X
: Rule 5
X + any subset of X = X
X = a + bc + abcd
X + a = X + bc + abcd = X
Loop
An infinite set of parallel paths.
b* = b0 + b1 + b2 + b3 +
X* = X0 + X1 + X2 + X3 +
X+ = X1 + X2 + X3 +
X X* = X* X = X+
n
0
1
X = X + X + X2 + X3 + + Xn
More Rules
Xm + Xn = Xn
if n m
= Xm
if n < m
m n
m+n
X X
= X
Xn X* = X* Xn = X*
Xn X+ = X+ Xn = X+
X* X+ = X+ X* = X+
Identity Elements ..
1 : Path of Zero Length
1+1 = 1
1X
= X1 = X
1n
= 1n = 1 * = 1 + = 1
1+ + 1 = 1 * = 1
0 : empty set of paths
X + 0 = 0+X = X
X0
= 0X = 0
0*
= 1 + 0 + 02 + 03 + . . . = 1
a a* = a* a = a+
: Rule 6
: Rule 7
: Rule 8
: Rule 9
: Rule 10
: Rule 11
: Rule 12
: Rule 13
: Rule 14
: Rule 15
: Rule 16
: Rule 17
Reduction Procedure
To convert a flow graph into a path expression that denotes the set of all entry/exit paths.
Node by Node Reduction Procedure
Initialization Steps
1. Combine all serial links by multiplying their path expressions.
2. Combine all parallel links by adding their path expressions.
3. Remove all self-loops - replace with links of the form X*
4. Select a non-initial & non-final 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 in-links with the set of out-links of that node.
5. Combine any serial links by multiplying their path expressions.
6. Combine any parallel links by adding their path expressions.
7. Remove all the self-loops.
( as in step 1)
( as in step 2)
( as in step 3)
P a g e | 58
8. IF theres just one node between entry & exit nodes, path expression for the flow graph is the links
path expression.ELSE, return to step 4.
Path Expression for a Flow Graph
is not unique
depends on the order of node removal.
P a g e | 59
Example
P a g e | 60
Identities/Rules
(A+B)*
=
( A* + B* ) *
: I1
=
( A* B* )*
: I2
=
( A* B )* A*
: I3
=
( B* A )* B*
: I4
=
( A* B + A )*
: I5
=
( B* A + B )*
: I6
(A+B+C+...)*
=
( A* + B* + C* + . . . )*
: I7
=
( A* B* C* . . . )*
: I8
Derived by removing nodes in different orders & applying the series-parallel-loop rules.
Properties
No cross-term transformation.
No GOTOs.
No entry into or exit from the middle of a loop.
Some examples
P a g e | 61