Docsity

State Transition Testing: A Technique for Software Testing, Lecture notes of Software Engineering

Partial preview of the text

Download State Transition Testing: A Technique for Software Testing and more Lecture notes Software Engineering in PDF only on Docsity!

Chapter 5:

Dynamic Analysis-Test Design Techniques

Software Testing

Lecture 5

State Transition Testing

State Transition Testing

Motivation:

Current input

History of execution or events or inputs

State Transition Testing:

Black box testing technique

Based on theory of finite state machine

State is a particular situation where a system can be.

Change in the state of the application under varying input.

State : has certain Attributes and behaviors

Transition is movement of one valid state to another valid state.

State Transition Testing – Important

Points

Verify

Different

States

Transaction

Goal

Valid States

Invalid States

Significance

To cover

sequence of

the states

Point 1 Point 2 Point 3

State Transition Testing – Important

Points

Example:

Analysis:

 Event cause the software to transition from one state to another and

perform transitions

 Conditions decide the transition path

Design State Transition

Two ways

State Transition Diagram

  • States are shown in boxed texts
  • Transition is represented by arrows.
  • It is also called State Chart or Graph.
  • It is useful in identifying valid transitions.

State transition table

  • Shows relationships between all states and events
  • STT consist of four columns—Current State, Event, Action, and Next State.
  • States can be listed on the left side
  • Events can be on the top.
  • Each cell in the table shows the state of the system after the event has occurred.
  • It is useful in identifying invalid transitions.

When to use State Transition Testing?

 Finite set of input values.

 Sequence of events

 Proper handling of a particular event

 Real time systems

State Transition Table Example 1

 Possible scenarios that need to be tested.

STT Example 2-Water

State transition diagram:

Invalid transition generally not shown in STD

Diagram with invalid transitions

STT Example 3-Dispensing machine

STT – Example 4

Example below is entering a Personal Identity Number (PIN) to a bank account. The states are

shown as circles, the transitions as lines with arrows and the events as the text near the

transitions.

States : S1:Start, S2:Wait for Pin, S3: 1st try, S4: 2nd Try, S5: 3rd Try, S6: access to account, S7:

eat card

Events: Event1:Card inserted, Event 2: enter Pin, Event 3: Pin OK, Event 4: Pin not OK

Actions : (not shown in the above example

Chow’s Coverage (Coverage of

tests)

 Chow's switch coverage describes how you cover a state transition model

 “Switch” here is state in between start and end state

0-switch coverage

  • Coverage of all individual transitions

-i.e. (no of exercised single-transitions in sequence ) x 100

(total no. of single-transitions in a sequence)

1-switch coverage

- coverage of transition pairs

-i.e (no of exercised two-transitions in sequence )* 100

(total no. of two-transitions in a sequence)

2-switch coverage

- coverage of transition triples

……….. N switch coverage.

STT-Testing Invalid Transitions

Example 4

  • STT shows relationships between all states and events
  • Resulting states and output
  • To see both valid and invalid, a State Table can be used.

-Invalid or Null Transitions are represented as ‘-‘ in red in the table above

Creating Test Cases

All events are triggered at least once

Note that the test cases that cover each event can be the same as those that

cover each state.

This is a weak level of coverage.

Creating Test Cases

All transitions are exercised at least once

Provides a good level of coverage

Generally the one recommended