Unit 4
Unit 4
UNIT IV
State, State Graphs and Transition testing: state graphs, good & bad state graphs, state
testing, Testability tips
Introduction
State is a condition or situation during which an object undergoes throughout its life
time.
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
softwarestructure, software behavior, or specifications of software behavior.
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
thetime being to a person or thing.”
A state graph consists of a set of states in order to represent the behavior of the system
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
States are represented by Nodes. State are numbered or may identified by wordsor
whatever else is convenient.
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
Software implementation
There is rarely a direct correspondence between programs and the behavior of a
processdescribed as a state graph.
The state graph represents, the total behavior consisting of the transport, the software,
theexecutive, the status returns, interrupts, and so on.
There is no simple correspondence between lines of code and states. The state table
formsthe basis.
For every transition there is one output action specified. The output could be
trivial, but at least one output does something sensible.
For every state there is a sequence of inputs that will drive the system back to the
same state.
Important graphs
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.
Transition Bugs
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.
Eventhe 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
thestate became unreachable as a result of incorrect transition.
There are two possibilities for unreachable states:
There is a bug; that is some transitions are missing.
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.
States or sets of states that have become dead.
States or sets of states that have become unreachable.
Whenever a feature is directly and explicitly implemented as one or more state transition
tables.