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.

126 Structuring <strong>Model</strong> Programs with Features and Composition<br />

0, 0<br />

1, 0<br />

2, 1<br />

2, 0<br />

Table 7.1. Pair states, enabled actions, and matched actions in M1 × M2<br />

Pair state M1 enabled actions M2 enabled actions<br />

(0, 0) A(), C() A(), B()<br />

(1, 0) B(2), C() A(), B( )<br />

(2, 1) C() A(), C()<br />

(2, 0) C() A(), B( )<br />

M1 A(), M2 A()<br />

M1 B(2), M2 B(_)<br />

M1 C(), M2 C()<br />

Figure 7.11. <strong>Model</strong> program M1 × M2, showing pair states and matched actions.<br />

the product is complete. The pair state (2, 0) is an accepting state in the product<br />

because both states in the pair are accepting states in their own programs.<br />

Table 7.1 summarizes this procedure. For each pair state, it shows the actions that<br />

are enabled in each loop extension, with the matching actions printed in bold type.<br />

Accepting states are also printed in bold type.<br />

There are a few additional complications that did not arise in this simple example,<br />

concerning the arguments of actions. When actions have the same name but different<br />

arguments (other than the placeholder), they do not match. For example, if M2 in<br />

this example had action B(3) instead of B( ), it would not match B(2) in M1 and no<br />

B action would appear in the product. Moreover, it is possible to define actions that<br />

have placeholders in any position, so the action D( ,4) in one program would match<br />

D(3, ) in another, resulting in D(3,4) in the product. More complex examples and<br />

explanations of composition appear in Chapter 14, especially Section 14.3.<br />

Sometimes it is useful to view the projection of a product onto one of the<br />

composed programs. Figure 7.12 shows the projection of the product M1 × M2 onto<br />

M2. The projection is generated by exploring the product. Each time the product<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!