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.

7 Structuring <strong>Model</strong><br />

Programs with<br />

Features and<br />

Composition<br />

In this chapter we describe two mechanisms for structuring model programs at<br />

a large scale: features and composition. Each provides a way to combine model<br />

programs in order to create a new one, or to write a model program as a collection<br />

of parts that are themselves complete (or nearly complete) model programs.<br />

Both mechanisms are so versatile that they can be used in many ways. In Chapter<br />

14 we use them to model interacting features. In this chapter we use them to<br />

limit analysis and testing to particular scenarios of interest. <strong>We</strong> also show how composition<br />

can be used in analysis to check temporal properties defined by sequences<br />

of actions.<br />

7.1 Scenario control<br />

The problem of limiting analysis and testing to particular runs of interest is called<br />

scenario control. Scenario control is necessary because we usually write a model<br />

program to act as a specification or contract, so it describes everything the implementation<br />

must do, might do, and must not do. As a result, the model program<br />

usually describes a large number of runs. When we analyze, and especially when<br />

we test, we usually do not want to consider all of these runs. <strong>We</strong> would like to limit<br />

our consideration to a particular scenario: a collection of runs (perhaps just one)<br />

that are pertinent to some issue.<br />

Here is an example that shows why we need scenario control. Figure 7.1 shows the<br />

true FSM we obtained by exploring the client/server model program we developed in<br />

Chapter 5, Section 5.6. There are many paths through this FSM; each path describes<br />

a different run. But is it useful to consider every run? In other words, does every<br />

run have a different effect? Let’s look more closely. Figure 7.2 shows the first few<br />

transitions of all the runs, where the client and server each perform the initial actions<br />

of the protocol shown in Chapter 2, Figure 2.2: the server executes Socket, Bind,<br />

more free ebooks download links at:<br />

http://www.ebook-x.com<br />

115

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!