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.

0<br />

A()<br />

1<br />

B(2)<br />

2<br />

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

Figure 7.6. <strong>Model</strong> program M1.<br />

shared actions that have the same name in two or more of the composed programs<br />

are one action in the product. They execute together, and can only execute when all<br />

of the actions are simultaneously enabled in each of their programs.<br />

The requirement in composition that shared actions must be enabled simultaneously<br />

in every composed program where they occur often has the effect of restricting<br />

behavior, eliminating some runs. That is why composition is useful for scenario control.<br />

Composition restricts behavior to the intersection of the runs of each composed<br />

program. In other words, the runs of the product are the runs that are allowed by<br />

every one of the composed programs. 1<br />

However, there is an important exception: Actions that are not shared can interleave<br />

in any order in the product, and can execute whenever they are enabled in<br />

their own programs. If you wish to suppress this interleaving, you must add those<br />

actions to the other model programs (so there are no longer any unshared actions),<br />

and disable those actions in every state in the other model programs.<br />

To summarize: Under composition, model programs synchronize steps for shared<br />

actions and interleave actions not found in their common action vocabulary.<br />

Here is a small example. M1 and M2 are model programs; for this discussion it is<br />

most helpful to show the FSM of each program. M1 has actions A() and B(2) that<br />

make transitions from the initial state 0 to state 1 to the accepting state 2 (Figure 7.6).<br />

M2 has actions B() and C() that make transitions from state 0 to 1 and back again;<br />

here state 0 is both the initial state and the accepting state (Figure 7.7). Their product<br />

M1 × M2 appears in Figure 7.8. All three actions appear in the product.<br />

1 Composition of model programs is a generalization of the construction of finite automata for<br />

the intersection of regular languages. For example, see the discussion following Theorem 3.3<br />

on pp. 59–60 of Hopcroft and Ullman (1979).<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!