Finite State Model-Based Testing on a Shoestring
By: Harry Robinson
Model-based testing is a software test technique that generates tests from an explicit model of software
behavior. Modern programmable test tools allow us to use this technique to create useful, flexible and
powerful tests at a very reasonable cost.
What Is Model-Based Testing?
Model-based testing is a technique that generates software tests from explicit descriptions of an
application’s behavior. Creating and maintaining a model of an application makes it easier to generate
and update tests for that application.
Several good model-based test tools are currently available in the market, but the techniques of modelbased
testing are not tied to any tool. This paper shows how anyone willing to do some test programming
can implement model-based testing in low-cost test language tools. The test language used in this paper
is Visual Test  from Rational Software.
In this paper, I will discuss how to use a test programming language to
1. Create a finite state model of an application.
2. Generate sequences of test actions from the model.
3. Execute the test actions against the application.
4. Determine if the application worked right.
5. Find bugs.
What Is A Model?
A model is a description of a system’s behavior. Because models are simpler than the systems they
describe, they can help us understand and predict the system’s behavior.
State models are common in computing and have been shown to be a useful way to think about software
behavior and testing . A finite state model consists of a set of states, a set of input events and the
relations between them. Given a current state and an input event you can determine the next current
state of the model.
As a running example throughout this paper, we will create a simple finite state model of the Windows NT
Clock application . The Clock can be found as Programs\Accessories\Clock under the Start menu in
Figure 1 shows two forms of the Clock display. The left side shows the Analog display; the right side
shows the Digital display. If the Clock application is in the Analog display mode, clicking the menu
selection “Settings\Digital” moves the application into the Digital display. Likewise, if the application is in
the Digital display mode, clicking the menu selection “Settings\Analog” moves the application into the
We could use this very simple state model as a basis for tests, where following a path in the model is
equivalent to running a test:
Setup: Put the Clock into its Analog display mode
Action: Click on “Settings\Digital”
Outcome: Does the Clock correctly change to the Digital display?
Create a Finite State Model of an Application
Finite state models are excellent tools for understanding and testing software applications. However, a
very large state model is needed to describe a complex system in enough detail to do a good job testing.
A finite state model used in representing the behavior of an application is likely to have many, many
states – so many that it would be tedious and unrealistic to create and maintain the model by hand.
The approach advocated in this paper allows you to generate large state models by describing the
behavior of an application in terms of a small number of state attributes called operational modes .
Operational modes are the attributes of a state that determine what user actions are possible in that state
and what outcomes will occur when actions are executed. For instance, whether or not the application is
currently running is a common operational mode. Typically, if the application is NOT running, the only
action the user can execute is to start the application. On the other hand, if the application IS running, the
user has a much greater choice of actions that could be performed.
For the purposes of this paper, we will only be concerned with the following actions in the Clock:
„h Start the Clock application
„h Stop the Clock application
„h Select Analog setting
„h Select Digital setting.
... to read more articles, visit http://sqa.fyicenter.com/art/