SlideShare a Scribd company logo
Chapter - 11
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
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 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.
None Z ZC ZCZ ZCZC
Z C Z C
Z
A,C Z,C,A
Z
A
A
A,C
States are represented by Nodes. State are numbered or may
identified by words or whatever else is convenient.
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 Transition.
 Transition are denoted by links that join the states.
 The input that causes the transition are marked on
the link; that is, the inputs are link weights.
 There is one outlink from every state for every
input.
 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………”.
Finite State Machine
 A finite state machine is an abstract device
that can be represented by a state graph
having a finite number of states and a
finite number of transitions between states.
Outputs
 An output can be associated with any link.
 Out puts are denoted by letters 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 transition causes
the same output, then denoted it as:
“input1, input2, input3…………../output”
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
STATE Z C A
NONE Z NONE NONE
Z Z ZC NONE
ZC ZCZ NONE NONE
ZCZ Z ZCZC NONE
ZCZC ZCZC ZCZC ZCZC
inputs
Time Versus Sequence
 State graphs don’t represent time-they represent
sequence.
 A transition 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 notion of time.
 Although the finite state machines model can be
elaborated to include notions of time in addition
to sequence, such as time Petri Nets.
Software implementation
 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
consisting of the transport, the software, the
executive, the status returns, interrupts, and so
on.
 There is no simple correspondence between lines
of code and states. The state table forms the
basis.
Good State Graphs and Bad
 What constitutes 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 software test design context.
 Here are some principles for judging.
 The total number of states is equal to the product of the
possibilities of factors that make up the state.
 For every state and input there is exactly one transition specified
to exactly one, possibly the same, state.
 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.
Improper State Graphs
State B can never be left, the initial state can
never be entered again.
C
1
State C cannot be entered.
States A and B are not reachable
Two transitions are specified for
an input of 1 in state A
A B
2
1 1,2
A
2
1
B
1,2
2
A B
1,2 1,2
A B
1 2
1,2
1
State Bugs-Number of States
 The number of states in a state graph is the number of states we
choose to recognize or model.
 The state is directly or indirectly recorded as a combination 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 setting
of two bit flags, leading to a total of 2*2*10=40 states.
 The number of states can be computed as follows:
 Identify all the component factors of the state.
 Identify all the allowable values for each factor.
 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.
Impossible States
 Some times some combinations of factors may
appear to be impossible.
 The discrepancy between the programmer’s state
count and the tester’s state count is often due to
a difference of opinion concerning “impossible
states”.
 A robust piece of software will not ignore
impossible states but will recognize them and
invoke an illogical condition handler when they
appear to have occurred.
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.
S
A
B
C
a
b
Merging of Equivalent States
S AB
a,b
C
Recognizing Equivalent States
 Equivalent states can be recognized by the
following procedures:
 The rows corresponding to the two states are
identical with respect to input/output/next state
but the name of the next state could differ.
 There are two sets of rows which, except for the
state names, have identical state graphs with
respect to transitions and outputs. The two sets
can be merged.
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 cant 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:
 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 inequivalent
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 testing is analogous to that
used for path testing flow graphs.
 Just as it’s impractical to go through every
possible path in a flow graph, it’s impractical to
go through every path in a state graph.
 The notion of coverage is identical to that used
for flowgraphs.
 Even though more state testing is done as a
single case in a grand tour, it’s impractical to do it
that way for several reasons.
Principles of State Testing-
continued.,
 In the early phases of testing, you will never
complete the grand tour because of bugs.
 Later, in maintenance, testing objectives are
understood, and only a few of the states and
transitions have to be tested. A grand tour is
waste of time.
 Theirs is no much history in a long test sequence
and so much has happened that verification is
difficult.
Starting point of state testing
 Define a set of covering input sequences that
get back to the initial state when starting from
the initial state.
 For each step in each input sequence, define the
expected next state, the expected transition,
and the expected output code.
 A set of tests, then, consists of three sets of
sequences:
1. Input sequences
2. Corresponding transitions or next-state names
3. Output sequences
Limitations and Extensions
 State transition coverage in a state graph model
doesnot guarantee complete testing.
 How defines 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 testing each transition individually.
 The next level consists of testing transitions
sequences consisting of two transitions called
“1 switches”.
 The maximum length switch is “n-1 switch”
where there are n number of states.
situations at which state testing
is useful
 Any processing where the output is based on the
occurrence of one or more sequences of events, such as
detection of specified input sequences, sequential format
validation, parsing, and other situations in which the
order of inputs is important.
 Most protocols between systems, between humans and
machines, between components of a system.
 Device drivers such as for tapes and discs that have
complicated retry and recovery procedures if the action
depends on the state.
 Whenever a feature is directly and explicitly implemented
as one or more state transition tables.

More Related Content

PPTX
Software testing ppt
PPTX
PPTX
Test case techniques
PPTX
Black box software testing
PPTX
Software Reliability
PDF
Cause effect graphing.ppt
PPTX
Mc call's software quality model
PPTX
Software development process models
Software testing ppt
Test case techniques
Black box software testing
Software Reliability
Cause effect graphing.ppt
Mc call's software quality model
Software development process models

What's hot (20)

PPT
Test case development
PPTX
Writing Test Cases 20110808
PPTX
Structural testing
PPTX
White box black box & gray box testing
PPTX
Ch 3 software quality factor
PDF
Black Box Testing
PPTX
Unit 2 - Test Case Design
PPTX
Best Practices for Test Case Writing
PPT
Manual testing concepts course 1
PPT
State transition testing-software_testing
PPTX
Software testing & Quality Assurance
PPSX
Test Execution
PPTX
Integration testing
PPTX
Unified process model
PPT
Chapter 13 software testing strategies
PDF
2- THE CHANGING NATURE OF SOFTWARE.pdf
PPT
Software Testing Fundamentals
PPT
Types of Software Testing
PPTX
PPT
Coupling and cohesion
Test case development
Writing Test Cases 20110808
Structural testing
White box black box & gray box testing
Ch 3 software quality factor
Black Box Testing
Unit 2 - Test Case Design
Best Practices for Test Case Writing
Manual testing concepts course 1
State transition testing-software_testing
Software testing & Quality Assurance
Test Execution
Integration testing
Unified process model
Chapter 13 software testing strategies
2- THE CHANGING NATURE OF SOFTWARE.pdf
Software Testing Fundamentals
Types of Software Testing
Coupling and cohesion
Ad

Similar to Fdocuments.in chapter 11-states-state-graphs-and-transition-testing (20)

PPTX
Stm unit- 4 r22 jntuh all topics covered
PPTX
States, state graphs and transition testing
PPTX
States, state graphs and transition testing
PDF
State, State Graphs and Transition testing: state graphs, good & bad state gr...
PDF
Finite automata
PPTX
Mgd finite statemachine
PPT
Logic and computer design.ppt
PDF
Fsm, games and ui development
PPT
072 swe415stnotes08
PPTX
Finite State Machine.ppt.pptx
PPTX
Transition System
PPT
Seminar State Chart1
PPTX
State modeling
PPT
Solving problems by searching
PPTX
20100522 software verification_sharygina_lecture01
PDF
Managing application-state-final
PPT
C:\documents and settings\student\desktop\swaroop uml
PPTX
Programming models for event controlled programs
PDF
Minimal Testcase Generation for Object-Oriented Software with State Charts
PPTX
state modeling In UML
Stm unit- 4 r22 jntuh all topics covered
States, state graphs and transition testing
States, state graphs and transition testing
State, State Graphs and Transition testing: state graphs, good & bad state gr...
Finite automata
Mgd finite statemachine
Logic and computer design.ppt
Fsm, games and ui development
072 swe415stnotes08
Finite State Machine.ppt.pptx
Transition System
Seminar State Chart1
State modeling
Solving problems by searching
20100522 software verification_sharygina_lecture01
Managing application-state-final
C:\documents and settings\student\desktop\swaroop uml
Programming models for event controlled programs
Minimal Testcase Generation for Object-Oriented Software with State Charts
state modeling In UML
Ad

Recently uploaded (20)

PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
Information Storage and Retrieval Techniques Unit III
PDF
Abrasive, erosive and cavitation wear.pdf
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
PPTX
Feature types and data preprocessing steps
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
Soil Improvement Techniques Note - Rabbi
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PDF
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
PPTX
communication and presentation skills 01
PDF
737-MAX_SRG.pdf student reference guides
PPTX
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PDF
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Information Storage and Retrieval Techniques Unit III
Abrasive, erosive and cavitation wear.pdf
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
distributed database system" (DDBS) is often used to refer to both the distri...
Feature types and data preprocessing steps
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
Soil Improvement Techniques Note - Rabbi
Fundamentals of safety and accident prevention -final (1).pptx
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
communication and presentation skills 01
737-MAX_SRG.pdf student reference guides
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
Exploratory_Data_Analysis_Fundamentals.pdf
Nature of X-rays, X- Ray Equipment, Fluoroscopy
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf

Fdocuments.in chapter 11-states-state-graphs-and-transition-testing

  • 1. Chapter - 11 STATES, STATE GRAPHS, AND TRANSITION TESTING
  • 2. 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 software behavior.  Finite state machines can also be implemented as table-driven software, in which case they are a powerful design option.
  • 3. 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
  • 4. 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.
  • 5. None Z ZC ZCZ ZCZC Z C Z C Z A,C Z,C,A Z A A A,C States are represented by Nodes. State are numbered or may identified by words or whatever else is convenient.
  • 6. 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 Transition.  Transition are denoted by links that join the states.  The input that causes the transition are marked on the link; that is, the inputs are link weights.  There is one outlink from every state for every input.  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………”.
  • 7. Finite State Machine  A finite state machine is an abstract device that can be represented by a state graph having a finite number of states and a finite number of transitions between states.
  • 8. Outputs  An output can be associated with any link.  Out puts are denoted by letters 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 transition causes the same output, then denoted it as: “input1, input2, input3…………../output”
  • 9. 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.
  • 10. State Table-Example STATE Z C A NONE Z NONE NONE Z Z ZC NONE ZC ZCZ NONE NONE ZCZ Z ZCZC NONE ZCZC ZCZC ZCZC ZCZC inputs
  • 11. Time Versus Sequence  State graphs don’t represent time-they represent sequence.  A transition 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 notion of time.  Although the finite state machines model can be elaborated to include notions of time in addition to sequence, such as time Petri Nets.
  • 12. Software implementation  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 consisting of the transport, the software, the executive, the status returns, interrupts, and so on.  There is no simple correspondence between lines of code and states. The state table forms the basis.
  • 13. Good State Graphs and Bad  What constitutes 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 software test design context.  Here are some principles for judging.  The total number of states is equal to the product of the possibilities of factors that make up the state.  For every state and input there is exactly one transition specified to exactly one, possibly the same, state.  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.
  • 14. Improper State Graphs State B can never be left, the initial state can never be entered again. C 1 State C cannot be entered. States A and B are not reachable Two transitions are specified for an input of 1 in state A A B 2 1 1,2 A 2 1 B 1,2 2 A B 1,2 1,2 A B 1 2 1,2 1
  • 15. State Bugs-Number of States  The number of states in a state graph is the number of states we choose to recognize or model.  The state is directly or indirectly recorded as a combination 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 setting of two bit flags, leading to a total of 2*2*10=40 states.  The number of states can be computed as follows:  Identify all the component factors of the state.  Identify all the allowable values for each factor.  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.
  • 16. Impossible States  Some times some combinations of factors may appear to be impossible.  The discrepancy between the programmer’s state count and the tester’s state count is often due to a difference of opinion concerning “impossible states”.  A robust piece of software will not ignore impossible states but will recognize them and invoke an illogical condition handler when they appear to have occurred.
  • 17. 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. S A B C a b
  • 18. Merging of Equivalent States S AB a,b C
  • 19. Recognizing Equivalent States  Equivalent states can be recognized by the following procedures:  The rows corresponding to the two states are identical with respect to input/output/next state but the name of the next state could differ.  There are two sets of rows which, except for the state names, have identical state graphs with respect to transitions and outputs. The two sets can be merged.
  • 20. 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 cant 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.
  • 21. 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:  There is a bug; that is some transitions are missing.  The transitions are there, but you don’t know about it.
  • 22. Dead States  A dead state is a state that once entered cannot be left.  This is not necessarily a bug but it is suspicious.
  • 23. 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.
  • 24. 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 inequivalent duplicates.  States or sets of states that have become dead.  States or sets of states that have become unreachable.
  • 25. Principles of State Testing  The strategy for state testing is analogous to that used for path testing flow graphs.  Just as it’s impractical to go through every possible path in a flow graph, it’s impractical to go through every path in a state graph.  The notion of coverage is identical to that used for flowgraphs.  Even though more state testing is done as a single case in a grand tour, it’s impractical to do it that way for several reasons.
  • 26. Principles of State Testing- continued.,  In the early phases of testing, you will never complete the grand tour because of bugs.  Later, in maintenance, testing objectives are understood, and only a few of the states and transitions have to be tested. A grand tour is waste of time.  Theirs is no much history in a long test sequence and so much has happened that verification is difficult.
  • 27. Starting point of state testing  Define a set of covering input sequences that get back to the initial state when starting from the initial state.  For each step in each input sequence, define the expected next state, the expected transition, and the expected output code.  A set of tests, then, consists of three sets of sequences: 1. Input sequences 2. Corresponding transitions or next-state names 3. Output sequences
  • 28. Limitations and Extensions  State transition coverage in a state graph model doesnot guarantee complete testing.  How defines 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 testing each transition individually.  The next level consists of testing transitions sequences consisting of two transitions called “1 switches”.  The maximum length switch is “n-1 switch” where there are n number of states.
  • 29. situations at which state testing is useful  Any processing where the output is based on the occurrence of one or more sequences of events, such as detection of specified input sequences, sequential format validation, parsing, and other situations in which the order of inputs is important.  Most protocols between systems, between humans and machines, between components of a system.  Device drivers such as for tapes and discs that have complicated retry and recovery procedures if the action depends on the state.  Whenever a feature is directly and explicitly implemented as one or more state transition tables.