Friday, April 18, 2008

Follow the State Transitions

One of the types of testing I like to do is state transition tests. This is useful in linear or near-linear workflows. Think the types of things that lend themselves to a workflow diagram.

Why?

The errors are in the gaps between the boxes.

Creating Your Test Cases
Ultimately, state transition tests are a tree search in which you must hit every node. I tend to use a breadth-first search, but you can do a depth-first search. The trick here is that you're not looking for one result, but for all possible paths.

An Example
This is a very very simple example:
Screen 1: Type in the IP address desired. OK / Cancel
Screen 2: Are you sure? Yes / No

Transitions from state 1 (format: input -> action -> result):
  • Valid IP -> click OK -> Screen 2
  • Invalid IP -> click OK -> Return to screen 1 with error message
  • Valid IP -> click Cancel -> Shut down machine
  • Valid IP -> turn off machine -> Machine shuts down
  • Invalid IP -> click Cancel -> Shut down machine
  • Invalid IP -> turn off machine -> Machine shuts down
Gotchas
The biggest gotcha with this method is that it creates a LOT of test cases. This is a case where you're going want to go through after creating your test cases and prune, prioritize, and/or automate.

Give it a try, and good luck!





No comments:

Post a Comment