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.

98 Exploring and Analyzing Finite <strong>Model</strong> Programs<br />

Messages<br />

TitlesOnly<br />

ByMostRecent<br />

Table 6.2. Newsreader true FSM: state transition table<br />

Current state Action Next state<br />

Topics, X, X SelectMessages Messages, –, –<br />

Messages, X, X SelectTopics Topics, –, –<br />

Topics, WithText, X ShowTitles –, TitlesOnly, –<br />

Topics, TitlesOnly, X ShowText –, WithText, –<br />

Topics, TitlesOnly, ByMostRecent SortByFirst –, –, ByFirst<br />

Topics, TitlesOnly, ByFirst SortByMostRecent –, –, ByMostRecent<br />

X indicates “don’t care” values in the current state, where any value will do<br />

– indicates “don’t change” values in the next state, where the value is the same as in the current state.<br />

Values shown are for the variables in this order: page, style, sort<br />

The initial state is Topics, WithText, ByMostRecent<br />

SelectMessages()<br />

Topics<br />

TitlesOnly<br />

ByMostRecent<br />

SelectTopics() ShowText() ShowTitles()<br />

Topics<br />

WithText<br />

ByMostRecent<br />

SelectMessages()SelectTopics()<br />

Messages<br />

WithText<br />

ByMostRecent<br />

SortByFirst()<br />

ShowText()<br />

Topics<br />

WithText<br />

ByFirst<br />

Messages<br />

WithText<br />

ByFirst<br />

Topics<br />

TitlesOnly<br />

ByFirst<br />

ShowTitles()<br />

SelectMessages() SelectTopics()<br />

Figure 6.2. Newsreader true FSM: state transition diagram.<br />

SortByMostRecent()<br />

SelectMessages() SelectTopics()<br />

Messages<br />

TitlesOnly<br />

ByFirst<br />

Compare the state transition table (Table 6.2) to the model program (Chapter 5,<br />

Figures 5.4 and 5.5). Notice that there is a row in the table for each action in the<br />

program, and notice how the current state and the next state entries in the table<br />

correspond to the enabling conditions and action methods in the program, respectively.<br />

In fact, we wrote the state transition table first, and coded the model program<br />

from it. This is often an effective way to design and code a model program that has<br />

a small number of states and actions.<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!