Note that there
must be two empty strings in the table at this point. By inspecting the implementation
we can see that when an element is deleted, a case is missing for the situation when
the count of the element that is deleted becomes 0. If this happens then the deletion
should also remove the element from the table. It is left as an exercise to the reader
to correct the two errors in the implementation and rerun ct.
12.4 Coverage-directed strategies
Coverage is a measure of how much testing has been done. Testing achieves better
coverage by exercising the implementation more thoroughly. A custom strategy can
be designed to achieve good coverage according to ameasure chosen by the designer.
The basic strategy provides random walks of a given number of steps, restarting
from the initial state each time. Purely random selection of actions may be wasteful,
and often one can do better. The basic idea is to keep a history of previously taken
steps. Here we look at how to implement a customized strategy for a given model
program that keeps track of a set of abstract coverage points. The algorithm that we
are presenting here should be seen as an example of how to implement your own
testing strategies, using the IStrategy and the ModelProgram interfaces as extension
points of the modeling library.
204 Testing Systems with Complex State
12.4.1 Coverage points
There are many ways to measure coverage.
Pages:
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275