1, and 7.2). The setup and cleanup sequences
in the scenario model program select one run through the many paths allowed by the
contract model program. The scenario model program does not mention the send
and receive actions; those are the test actions that are allowed to interleave.
This command displays the test scenario model program composed with the
contract model program:
mpv /fsm:Scenario.txt /r:ClientServer.dll ClientServer.Factory.Create
Figure 7.15 shows the result. The setup and cleanup sequences from the scenario
model program also appear in the product. The loops in the middle of the diagram
represent the interleaving of the test actions, send and receive. We will use this
product in Chapter 8 to generate and check tests that reveal the defect we discussed
in Chapter 2.
7.4 Choosing among options for scenario control
There are three ways to control the scenarios of a model program: enabling conditions,
features, or composition. We recommend that the model program should
be a specification or contract, so its enabling conditions should permit all allowed
runs, not just particular scenarios. Scenario control should be separated out with
features or composition, so the same contract model program can analyze or test
different scenarios. Features can access the model program state, so use features for
130 Structuring Model Programs with Features and Composition
0
1
ServerSocket()
9
2
ServerBind()
3
ServerListen()
4
ClientSocket()
5
ClientConnect()
6
ServerAccept()
7
ClientClose()
8
ServerCloseConnection()
ServerClose()
Figure 7.
Pages:
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194