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.

Advanced Topics 229<br />

FSM(0, AcceptingStates(0),<br />

Transitions(t(0,ReqSetup(0,0),0), t(0,ReqSetup(0,1),0),<br />

t(0,ResSetup(0,0),0), t(0,ResSetup(0,1),0)),<br />

Vocabulary("ReqWork", "ResWork"))<br />

Figure 14.2. A parameter restriction scenario for the credits model.<br />

3<br />

0<br />

ReqA(0,1)<br />

1<br />

ResA(0,1) ResA(0,0)<br />

2<br />

Figure 14.3. Composition of the model programs in Figures 14.1 and 14.2. State 2 violates the state invariant<br />

in Figure 14.1.<br />

Figure 14.2). The FSM disables all Work actions and provides concrete parameter<br />

domains for message IDs and credits in the Setup actions. <strong>We</strong> can compose the<br />

credits model program with the FSM. The resulting finite state machine is shown in<br />

Figure 14.3. <strong>We</strong> can see that state 2 is unsafe, because the update rule of the action<br />

ResSetup(0,0, ) from state 1 removes all pending requests and adds no credits, so<br />

the client cannot send further requests.<br />

<strong>We</strong> need to strengthen the enabling condition of the response action so that if<br />

there are no pending requests and the window is empty, then the granted number of<br />

credits must be at least one. <strong>We</strong> do so by adding the additional enabling condition<br />

to the credits model.<br />

[Requirement("Section ...: Client must have enough credits")]<br />

static bool ResEnabled1(int m, int c)<br />

{<br />

return requests.Count > 1 || window.Count > 0 || c > 0;<br />

}<br />

Notice that if the window is empty and no credits are granted then there must be<br />

at least two requests pending when this enabling condition is checked, because the<br />

response action update rule will remove one of the requests.<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!