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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

states 0 and 2 have been explored.) The algorithm terminates when the frontier is<br />

empty.<br />

If the model program is finite, this algorithm always terminates. When it does,<br />

the collection of transitions is the true FSM. Variations are possible. In Figure 6.7<br />

the frontier is a sequence and new states are appended to the tail. This results in<br />

breadth-first exploration of the graph of the FSM. If new states were pushed on the<br />

head, depth-first exploration would occur instead. When exploration is exhaustive,<br />

as it is here, the final result is the same; otherwise, the two strategies explore different<br />

subsets of the true FSM.<br />

Interactive exploration works almost the same way. Instead of working through<br />

the frontier sequentially until it is empty, interactive exploration allows the user<br />

to choose elements from the frontier in any order, and to exit at any time. Where<br />

exhaustive exploration has this:<br />

while (!frontier.IsEmpty)<br />

{<br />

State current = frontier.Head; // choose first element of frontier<br />

frontier = frontier.Tail; // all but first element of frontier<br />

...<br />

Interactive exploration has something like this:<br />

while (!frontier.IsEmpty && still_interested)<br />

{<br />

State current = frontier.Choose(i); // choose an element of frontier<br />

frontier = frontier.Remove(current); // remove that element<br />

...<br />

This same algorithm can be easily extended to explore infinite model programs,<br />

because it is lazy: it delays computing each next state until it is needed, growing<br />

the FSM on the frontier as it goes, always adding to an incomplete subset of the<br />

true FSM. To limit exploration it is only necessary to add a stopping rule to exit<br />

before the frontier is empty. In fact, the mpv tool already provides one stopping rule:<br />

exploration stops after a certain number of transitions, MaxTransitions, has been<br />

found. It could be coded this way:<br />

while (!frontier.IsEmpty && transitions.Count < MaxTransitions)<br />

...<br />

In mpv, MaxTransitions can be set on the command line, in a configuration file, or<br />

in the graphical user interface.<br />

In this simplified description we have not discussed parameter generation, which<br />

assigns values to the parameters of action methods. Recall that parameter values are<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!