27.07.2013 Views

2 Why We Need Model-Based Testing

2 Why We Need Model-Based Testing

2 Why We Need Model-Based Testing

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Systems with Finite <strong>Model</strong>s 103<br />

more automatic way that uses composition to check whether a run is allowed, which<br />

is still simpler than writing a unit test.<br />

6.2.4 An exploration algorithm<br />

In this subsection we explain how exploration works by presenting an exploration<br />

algorithm. You do not need to understand the algorithm in order to use the mpv<br />

tool to analyze finite model programs. But to analyze infinite model programs,<br />

you must provide additional information to guide exploration (Chapter 11). Then it<br />

becomes necessary to understand how exploration works. <strong>We</strong> prepare for that now<br />

by considering exhaustive exploration, which is the simplest case.<br />

Exploration generates an FSM from a model program. It executes the model<br />

program, automatically selecting actions to execute, monitoring, and recording each<br />

state transition as it occurs, building a data structure that contains all the information<br />

shown in state transition tables or diagrams (Table 6.2, Figure 6.2).<br />

Recall that we prepare for exploration by providing a factory method that creates<br />

a Library<strong>Model</strong>Program object from the compiled model program assembly<br />

(Section 6.2.1, Figure 6.3). Exploration executes the model program indirectly, by<br />

invoking the methods of this object.<br />

The Library<strong>Model</strong>Program class is derived from the <strong>Model</strong>Program base class. <strong>We</strong><br />

now provide a simplified description of this class, which omits many details. The<br />

names and members (etc.) of the types and methods in this simplified description<br />

are not the same as in the actual library. To avoid confusion with the actual modeling<br />

library, we call the class <strong>Model</strong>ProgramSimple here. It uses these types (which are<br />

also not exactly the same as the ones in the actual modeling library):<br />

State The state of a model program, represented by a dictionary that associates<br />

each state variable name with its value.<br />

Action The invocation of an action, including the action method name and all of<br />

its arguments.<br />

Transition A state transition, with constructor Transition(State current,<br />

Action a, State next)<br />

Our <strong>Model</strong>ProgramSimple class provides these properties and methods:<br />

State InitialState Property that returns the model program’s initial state<br />

Set GetActions(State s) Method that returns the set of actions that<br />

are enabled in state s.<br />

State GetTargetState(State s, Action a) Method that returns the next state<br />

reached by executing action a in the current state s.<br />

more free ebooks download links at:<br />

http://www.ebook-x.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!