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.

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

For parameter generation one can also use dependent features of model programs<br />

if parameter selection is most conveniently done by reading the state of the contract<br />

model program.<br />

14.4.4 Property checking<br />

One can write a model program to describe a temporal property that describes a “bad”<br />

behavior of the contract. For example, a certain pattern of actions leads to a state<br />

where a safety condition in the property model program is violated. Composition of<br />

the contract model program with the property model program can be explored for<br />

safety analysis (as we demonstrated in Chapter 7, Section 7.5).<br />

One can also write a state-dependent condition in a separate feature that reads<br />

state variables of multiple features and defines a global safety condition spanning<br />

those features. It is asssumed here that the feature model programs use distinct state<br />

variables, so the safety condition is not specific to any single feature model program.<br />

14.4.5 State refinement<br />

One can use composition to abstract details of subbehaviors. The idea is the following.<br />

Suppose you have a model program A that includes two actions StartB() and<br />

FinishB(). There is another model program B that describes the behavior of B. The<br />

only action symbols that A and B have in common are StartB() and FinishB(). When<br />

A is explored in isolation, then StartB() leads to a state "B-Is-Working" where the<br />

only enabled action is FinishB(). The only action that is initially enabled in B is<br />

StartB() and the last action of B is FinishB(). A composition of A and B provides<br />

a refinement of the state "B-Is-Working" where all the behavior of B is included.<br />

14.5 Exercises<br />

1. Finish the model program M for M1 × M2 that was started in Section 14.3.1 for<br />

all actions. Use mpv to convince yourself that the traces of M are the same as the<br />

traces of M1 × M2.<br />

2. Extend the previous exercise to include also the credits model program and the<br />

commands model program.<br />

3. Write a model program M with two features F1 and F2 such that F1 and F2 share<br />

state variables and use the same actions A and B, and the set of traces of M is<br />

not an intersection of the set of traces of M restricted to F1 and the set of traces<br />

of M restricted to F2.Usempv to check the result.<br />

4. Write a utility that given a regular expression over actions (possibly including<br />

placeholders) generates the corresponding FSM.<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!