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.

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

0<br />

ServerSocket()<br />

1<br />

ServerClose()<br />

ServerBind()<br />

3<br />

2<br />

ServerListen()<br />

ServerClose() 4<br />

ServerClose()<br />

Figure 7.4. Client/server: server feature included, client feature not included.<br />

all of its action methods are true (in all the included features and other classes).<br />

During exploration, the combined action is executed repeatedly in each state, with<br />

each combination of parameter values that is enabled in all of the features. When<br />

the combined action executes, all of the action methods for that action execute, as if<br />

in parallel (actually, in some order that cannot be predicted). This only makes sense<br />

if the next state after executing all the action methods is the same for any order of<br />

execution. This is assured if none of the action methods assigns state variables that<br />

are used by other action methods in the same action.<br />

Here we show how to combine features to control parameter generation, an<br />

aspect of scenario control. Recall that each parameter of each action method must<br />

be provided with a domain, a set of argument values for that parameter. In each<br />

state, exploration executes each action method repeatedly, using as many different<br />

values as it can from the domains of all its parameters, so larger domains result in<br />

more transitions and more runs. Therefore, selecting domains can limit or select<br />

runs. In our examples in Chapter 5, each domain is coded directly into the contract<br />

model program. In the client/server example, one particular domain Temperatures<br />

is always used for the datum parameter of the ServerSend action method:<br />

[Action]<br />

static void ServerSend([Domain("Temperatures")] double datum)<br />

...<br />

static Set Temperatures()<br />

...<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!