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.

Advanced Topics 267<br />

condition can be relaxed when the model program is used for on-the-fly testing with<br />

observable actions.<br />

Given a set of action symbols A, a model program is explorable for A if the<br />

parameters of all the actions in A have finite domains in all states. For on-the-fly<br />

testing with observable actions, the model program does not need to be explorable<br />

for observable actions. The reason is that the arguments for the observable actions<br />

are provided by the stepper. Recall that the fundamental property of model program<br />

exploration is that it is lazy. During on-the-fly testing, an observable action is<br />

executed in the model program only when it has occurred in the implementation, at<br />

which point all the parameters have been provided.<br />

Consider the model program SP[Credits,Commands,Setup] with the three included<br />

features from Chapter 14. Notice that Cancel is not in the action vocabulary<br />

of that model progam. Let us add another feature to SP that restricts the parameters<br />

of all the request actions so that each request asks for 3 credits and the requests use<br />

ids from the window of allowed message ids.<br />

namespace SP<br />

{<br />

[Feature]<br />

public static class ReqParams<br />

{<br />

readonly static Set C = new Set(3);<br />

readonly static Set M() { return Credits.window; }<br />

[Action("ReqSetup(m,c)")]<br />

[Action("ReqWork(m,c)")]<br />

static void Req([Domain("M")]int m, [Domain("C")]int c){ }<br />

}<br />

}<br />

The model program SP[Credits,Commands,Setup<strong>Model</strong>,ReqParams] is explorable<br />

for controllable actions but not for observable actions. Nevertheless, it is possible to<br />

run ct with the following options, where SP.OTFTest.Make is a factory method for<br />

this model program.<br />

/r:SPImpl.dll /r:SP.dll SP.OTFTest.Make /iut:SPImpl.Stepper.Make<br />

/o:ResWork /o:ResSetup<br />

The following is a sample output that shows a conformance failure similar to the<br />

one shown in Figure 16.1. Notice that the reason in the failure has been extracted<br />

from the requirement attribute of the ResEnabled1 condition in Section 14.2.1 that<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!