Software Testing Methodologies Notes-UNIT-V
Software Testing Methodologies Notes-UNIT-V
asia
UNIT V
STATES, STATE GRAPHS, AND TRANSITION TESTING
Introduction
The finite state machine is as fundamental to software engineering as boolean algebra
to logic.
State testing strategies are based on the use of finite state machine models for software
structure, software behavior, or specifications of softwarebehavior.
Finite state machines can also be implemented as table-driven software, in which
case they are a powerful design option.
State Graphs
A state is defined as: “A combination of circumstances or attributes belonging for the
time 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.
jntuworldupdates.org Specworld.in
Smartzworld.com Smartworld.asia
If several inputs in a state cause a transition to the same subsequent state, instead of
drawing a bunch of parallel links we can abbreviate the notation by listing the several
inputs as in: “input1, input2, input3………”.
State Tables
Big state graphs are cluttered and hard to follow.
It’s more convenient to represent the state graph as a table (the state table or
state transition table) that specifies the states, the inputs, the transitions and
the outputs.
The following conventions are used:
Each row of the table corresponds to a state.
Each column corresponds to an input condition.
The box at the intersection of a row and a column specifies the next state (the
transition) and the output, if any.
State Table-Example
jntuworldupdates.org Specworld.in
Smartzworld.com Smartworld.asia
Important graphs
jntuworldupdates.org Specworld.in
Smartzworld.com Smartworld.asia
Equivalent States
Two states are Equivalent if every sequence of inputs starting from one state produces
exactly the same sequence of outputs when started from the other state. This notion can
also be extended to set of states.
jntuworldupdates.org Specworld.in
Smartzworld.com Smartworld.asia
TransitionBugs-
unspecified and contradictory Transitions
Every input-state combination must have a specified transition.
If the transition is impossible, then there must be a mechanism that prevents the
input from occurring in that state.
Exactly one transition must be specified for every combination of input and state.
A program can’t have contradictions or ambiguities.
Ambiguities are impossible because the program will do something for every input.
Even the state does not change, by definition this is a transition 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 transitions from unreachable state to other states; there usually because
the state became unreachable as a result of incorrect transition.
There are two possibilities for unreachable states:
o There is a bug; that is some transitions are missing.
o The transitions are there, but you don’t know about it.
Dead States
A dead state is a state that once entered cannot be left.
This is not necessarily a bug but it is suspicious.
Output Errors
The states, transitions, and the inputs could be correct, there could be no dead
or unreachable states, but the output for the transition could be incorrect.
Output actions must be verified independently of states and
transitions. State Testing
Impact of Bugs
If a routine is specified as a state graph that has been verified as correct in all
details. Program code or table or a combination of both must still be implemented.
A bug can manifest itself as one of the following symptoms:
Wrong number of states.
Wrong transitions for a given state-input combination.
Wrong output for a given transition.
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.
jntuworldupdates.org Specworld.in
Smartzworld.com Smartworld.asia
jntuworldupdates.org Specworld.in
Smartzworld.com Smartworld.asia
Tool Building
If you build test tools or want to know how they work, sooner or later you will be implementing
or investigating analysis routines based on these methods.
It is hard to build algorithms over visual graphs so the properties or graph matrices are
fundamental to tool building.
jntuworldupdates.org Specworld.in
Smartzworld.com Smartworld.asia
A simple weight
A simplest weight we can use is to note that there is or isn’t a connection. Let “1” mean that there
is a connection and “0” mean that there isn’t.
The arithmetic rules are:
1+1=1 1*1=1
1+0=1 1*0=0
0+0=0 0*0=0
A matrix defined like this is called connection matrix.
Connection matrix
The connection 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 clutter.
jntuworldupdates.org Specworld.in
Smartzworld.com Smartworld.asia
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 junction is node with more than one nonzero entry in its column.
A self loop is an entry along the diagonal.
Cyclomatic Complexity
The cyclomatic complexity obtained by subtracting 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 cyclomatic complexity.
jntuworldupdates.org Specworld.in
Smartzworld.com Smartworld.asia
Relations
A relation 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 relation R between the nodes.
If aRb, which is to say that a has the relation R to b, it is denoted by a link froma to b.
For some relations we can associate properties called as linkweights.
Transitive Relations
A relation is transitive if aRb and bRc implies aRc.
Most relations used in testing are transitive.
Examples of transitive relations include: is connected to, is greater than or equal to, is less than or
equal to, is a relative of, is faster than, is slower than, takes more time than, is a subset of,
includes, shadows, is the boss of.
Examples of intransitive relations include: is acquainted with, is a friend of, is a neighbor of,
is lied to, has a du chain between.
Reflexive Relations
A relation R is reflexive if, for every a, aRa.
A reflexive relation is equivalent to a self loop at every node.
Examples of reflexive relations include: equals, is acquainted with, is a relative of.
Examples of irreflexive relations include: not equals, is a friend of, is on top of, is under.
Symmetric Relations
A relation R is symmetric if for every a and b, aRb implies bRa.
A symmetric relation mean that if there is a link from a to b then there is also a link from b to a.
A graph whose relations are not symmetric are called directed graph.
jntuworldupdates.org Specworld.in
Smartzworld.com Smartworld.asia
Antisymmetric Relations
A relation R is antisymmetric if for every a and b, if aRb and bRa, then a=b, or they are the
same elements.
Examples of antisymmetric relations: is greater than or equal to, is a subset of, time.
Examples of nonantisymmetric relations: is connected to, can be reached from, is greater than,
is a relative of, is a friend of
quivalence Relations
An equivalence relation is a relation that satisfies the reflexive, transitive, and
symmetric properties.
Equality is the most familiar example of an equivalence relation.
If a set of objects satisfy an equivalence relation, we say that they form an equivalence class
over that relation.
The importance of equivalence classes and relations is that any member of the equivalence
class is, with respect to the relation, equivalent to any other member of that class.
The idea behind partition testing strategies such as domain testing and path testing, is that we can
partition the input space into equivalence classes.
Testing any member of the equivalence class is as effective as testing them all.
jntuworldupdates.org Specworld.in
Smartzworld.com Smartworld.asia
Partitioning Algorithm
Consider any graph over a transitive relation. The graph may have loops.
We would like to partition the graph by grouping nodes in such a way that every loop is
contained within one group or another.
Such a graph is partially ordered.
There are many used for an algorithm that does that:
We might want to embed the loops within a subroutine so as to have a resulting graph which is
loop free at the top level.
Many graphs with loops are easy to analyze if you know where to break the loops.
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.
jntuworldupdates.org Specworld.in