9")),
ClientSend(),
ServerReceive(),
ServerSend(double("100")),
ClientReceive_Start(),
ClientReceive_Finish(double("100")),
ClientSend(),
ServerReceive(),
ClientSend(),
ServerReceive(),
ClientClose(),
ServerCloseConnection(),
ServerClose()
)
)
This test succeeded because the server didn??™t send 100 until the last message.
After a few more random test runs, ct executes a run that fails, revealing the
defect.
This example shows that a random test strategy generates a lot of test runs easily;
it is no more work for us to set /nruns:1000. But many of those randomly generated
runs do not exercise the implementation thoroughly, so in this example the built-in
random strategy does not achieve good coverage rapidly. We can often do better
by programming our own strategy, which we can load into ct with the /strategy
option. The following sections show how.
194 Testing Systems with Complex State
12.2 Implementation, model and stepper
For the example in this chapter we use an implementation of a bag, shown in
Figure 12.1, as a sample IUT throughout this section to illustrate various techniques
that can be used for on-the-fly testing. This example is small and easy to understand
while it naturally leads to a model program with complex state and infinite behavior.
It helps to illustrate on a smaller scale many of the properties of more complex
model programs that use state variables with unbounded data types.
Pages:
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264