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.

230 Compositional <strong>Model</strong>ing<br />

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

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

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

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

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

Figure 14.4. Another scenario,CreditsScenario2, for the Credits model program. Message IDs are 0<br />

and 1. Requests ask for two credits. Responses grant up to two credits.<br />

ReqSetup(0, 2)<br />

0 1<br />

ResSetup(0, 2)<br />

ResSetup(0, 1)<br />

2<br />

ReqSetup(1, 2)<br />

ReqSetup(1, 2)<br />

3 5<br />

4<br />

ResSetup(1, 2)<br />

ResSetup(1, 0)<br />

ResSetup(1, 1)<br />

ResSetup(1, 1)<br />

ResSetup(1, 2)<br />

Figure 14.5. Composition of the scenario in Figure 14.4 with the amended credits model program.<br />

Let us consider another scenario that allows two message IDs to be used and<br />

assumes that the client always requests two credits, whereas the server grants at<br />

most two credits (see Figure 14.4). The full exploration of the composition of this<br />

scenario with the amended credits model program is shown in Figure 14.5.<br />

14.2.2 Message parameters<br />

It is useful to identify those parameter domains of actions that have finite domains<br />

that can be derived from the model program state. These domains can be used<br />

to make the model program explorable. Recall that for a model program to be<br />

explorable, all action parameters must have finite domains. Looking at the credits<br />

model program for example, we can see that all responses from the server must<br />

have message identifiers present in the requests map. Also, all granted credits from<br />

the server must be between zero and the maximum credit requested by the client.<br />

<strong>We</strong> add these derived parameter domains as another feature model program to SP<br />

(see Figure 14.6).<br />

Notice that this feature has no state variables of its own. It is a dependent feature<br />

of the credits feature model program. <strong>We</strong> could also have annotated the credits<br />

feature model program in Figure 14.1 directly, but it is useful to keep the dependent<br />

feature separate for readability and for later use in compositions. In some cases the<br />

dependent feature is not needed and can be omitted.<br />

more free ebooks download links at:<br />

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

8<br />

7<br />

6

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

Saved successfully!

Ooh no, something went wrong!