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.

198 <strong>Testing</strong> Systems with Complex State<br />

model program as arguments. Notice that the ElementRestriction feature has a<br />

void Lookup Start method as opposed to a Lookup method that returns an integer.<br />

This is because the feature does not need to restrict the return values. Using features<br />

to restrict parameter domains is one possible use of features. <strong>We</strong> discuss more<br />

about the use of features in forthcoming sections. The scenario model produced by<br />

CreateScenario is still infinite because the size of the bag is unbounded. However,<br />

unlike the Contract model program, the model program created by CreateScenario<br />

is explorable because all parameter domains are finite.<br />

Often it is useful to identify a particular set of states of a model program or<br />

a restricted model program as accepting states. A legal run must terminate in an<br />

accepting state. What states are considered as accepting states may depend on what<br />

features are considered. The feature in Figure 12.3 defines that the accepting state<br />

condition for this feature is that the bag is empty; thus, the initial state is the only<br />

accepting state in this case. If no accepting state condition is provided then all<br />

states are considered as accepting states. If multiple features are considered then<br />

the accepting state condition is the conjunction of all the accepting state conditions<br />

present in the included features.<br />

12.2.3 Stepping the implementation<br />

Recall that an IUT is exposed through a stepper (Section 8.3). The stepper “steps”<br />

through the IUT one action at a time. It has a current state that corresponds to the<br />

current state of the IUT. Initially, the stepper’s current state corresponds to the IUT’s<br />

initial state.<br />

When the stepper performs an action, it calls the IUT with the corresponding input<br />

arguments. The inputs encoded in the action are abstract and are not necessarily the<br />

concrete values required by the IUT. However, there must be a well-defined mapping<br />

from abstract input actions to concrete input values. This mapping is an integral part<br />

of the stepper.<br />

Performing an action in the stepper may cause the stepper to return an output<br />

action as a return value. This action either corresponds to the immediate return value<br />

of a method or represents an abstraction of the resulting state of the IUT. There must<br />

be a well-defined mapping from the concrete return values of the IUT to the abstract<br />

actions returned by the stepper.<br />

Steppers are implementations of the modeling library’s IStepper interface.<br />

public interface IStepper<br />

{<br />

Action DoAction(Action action);<br />

void Reset();<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!