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.

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

14.2.6 Composing the features<br />

Let us now consider a composition of all of the features. <strong>We</strong> also need some scenarios<br />

to restrict the parameter domains, so that the composed model program becomes<br />

explorable. <strong>We</strong> consider two scenarios shown in Figure 14.16.<br />

The scenario CreditScenario describes a client who always uses the minimum<br />

available request ID and asks for two credits when sending a request. The scenario<br />

also limits the number of requests to three. In addition, the scenario describes a<br />

“generous” server who always grants the maximum number credits to the client.<br />

Note that this scenario model program is a dependent feature of the credits model<br />

program and can therefore not be explored independently of it.<br />

The second scenario, called CancelScenario, describes a client that cancels only<br />

the last request that was sent, and only if there is more than one request pending.<br />

This scenario is also a dependent feature of the sample protocol model because it<br />

references the state of the cancellation model program.<br />

Full exploration of the sample protocol model with all the features composed<br />

with the scenarios in Figure 14.16 is shown in Figure 14.17. Notice how the features<br />

interact by synchronizing on actions whose symbols are shared. The allowed action<br />

traces of the composed model program belong to the intersection of the traces of the<br />

individual model programs.<br />

A valid trace of actions is illustrated in Figure 14.18. In this trace all requests<br />

were completed, even though request 1 was cancelled by the client. The status field<br />

in the response actions comes from the cancellation model program, whereas the<br />

allowed message IDs come from the credits model program. The fact that setup<br />

has to precede work is due to the setup model program. In state 2 the window<br />

of the credits model program is the set {3, 4, 5, 6} and all the map-valued state<br />

variables are empty maps. If we would remove the restriction that the server always<br />

grants the maximum number of credits, we would obtain a state transition graph<br />

that represents all the valid server behaviors for the given client behaviors. The<br />

state graph would have 24 states and 62 transitions. The final state of every valid<br />

trace would have a credits window equal to one of the sets {3}, {3, 4}, {3, 4, 5},<br />

or {3, 4, 5, 6}, depending on the actual number credits granted by the server in the<br />

responses.<br />

For visual validation of the behavior it is useful to restrict the size of the explored<br />

state space to a small portion of the full state space. However, if the client is<br />

being controlled by the tester and the server is observed only by the tester, it is<br />

important not to restrict the behavior of the server in order to use the composition<br />

as a test oracle. Restricting the observable behavior in the composition may lead<br />

to false negatives during testing. <strong>Testing</strong> with observable actions is the topic of<br />

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