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.

4<br />

Advanced Topics 263<br />

3<br />

Add("b")<br />

Draw_Start()<br />

Add("a")<br />

2<br />

Add("b")<br />

Draw_Start()<br />

10<br />

6<br />

1<br />

Draw_Finish("a")<br />

Draw_Finish("b")<br />

0<br />

Add("a")<br />

Draw_Start()<br />

Draw_Finish("b")<br />

Draw_Finish("a")<br />

8<br />

0<br />

Add("a") Draw() / "a"<br />

1<br />

Add("b") Draw() / "b"<br />

3<br />

Draw() / "a" Add("a")<br />

2<br />

Add("b") Draw() / "b"<br />

(a) (b)<br />

Figure 16.3. Partial exploration of Bag<strong>Model</strong>[Draw]. In (b) passive states are hidden.<br />

The model program has two new actions Draw Start() and Draw Finish(e),<br />

where the first action represents a request to draw and the second action represents<br />

a particular element e that was drawn. This action is nondeterministic because any<br />

element in the bag might be drawn (any element from the domain B might be chosen).<br />

The state variable drawing is used to disable all actions besides Draw Finish until<br />

the draw operation has been completed.<br />

A partial exploration of Bag<strong>Model</strong>[Draw] with mpv is illustrated in Figure 16.3.All<br />

passive states are shown as diamonds in Figure 16.3(a). (The mpv tool can generate<br />

a partial exploration interactively, as described in Chapter 6, Section 6.2.3.) The<br />

nondeterminism is indicated by the two Draw Finish transitions exiting from state 6<br />

in Figure 16.3(a) and the two Draw transitions exiting from state 3 in Figure 16.3(b).<br />

more free ebooks download links at:<br />

http://www.ebook-x.com<br />

4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!