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 97<br />

disabled in that state. Every transition out of a state is labeled with one of the<br />

actions that is enabled in that state. For example, in the middle node in Figure 6.1,<br />

two actions are enabled: SortByFirst and ShowText. The heart of the traversal<br />

algorithm can be expressed: in each state, choose an enabled action and execute it.<br />

By this algorithm, we can obtain the original run we used to define this FSM (from<br />

Chapter 5, Section 5.5). <strong>We</strong> can also obtain many other runs from this same FSM by<br />

choosing other transitions (other enabled actions), traversing different paths around<br />

the links in the diagram (possibly repeating each cycle many times). For example,<br />

the diagram in Figure 6.1 describes many runs that begin<br />

ShowTitles(); SortByFirst(); SortByMostRecent(); ShowText(); ...<br />

There are many more runs that begin<br />

ShowTitles(); ShowText(); ShowTitles(); SortByFirst(); ...<br />

And so on. A run obtained by traversing a graph is sometimes called a traversal or<br />

an unwinding. A collection of related runs is called a scenario. The entire collection<br />

of runs that can be generated from an FSM is called the scenario defined by that<br />

FSM.<br />

Traversing an FSM generated by exploration from a model program is our offline<br />

test generation technique. Different traversal algorithms can achieve different<br />

measures of behavioral coverage (Chapter 8).<br />

6.1.2 Scenario FSMs and the true FSM<br />

An FSM whose purpose is to define a scenario is called a scenario FSM. Itis<br />

possible to define many different scenario FSMs for any model program; each<br />

different scenario FSM defines a different collection of runs. There is one FSM that<br />

can generate all of the runs of a model program: its true FSM.<br />

When the model program has a small number of states and actions, it is possible to<br />

write down its true FSM. Table 6.2 and Figure 6.2 show the state transition table and<br />

the state transition diagram, respectively, for the true FSM of our newsreader model<br />

program (Chapter 5, Figures 5.4 and 5.5). Notice that the states and transitions in<br />

Figure 6.1 also appear in Figure 6.2 (the initial state is shaded in both diagrams).<br />

Here in Table 6.2, we use a more compressed format than in Table 6.1. <strong>We</strong> merge<br />

several transitions into each row by using X to indicate “don’t care” values in the<br />

current state (where any value of particular variable is handled the same way, or is<br />

simply ignored) and a dash (–) for “don’t change” values in the next state (where<br />

the value of a particular variable is the same as in the current state). It turns out that<br />

here this compression results in just one row for each action. Notice that each row<br />

in Table 6.1 is also represented (in compressed format) in Table 6.2.<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!