The reserved name for getting all the
coverage points that are covered by executing an annotated action from a given
state is "CoveragePoints".
Bag
GetCoveragePoints(IState s, Action a)
{
Bag cps;
model.GetTargetState(s, a, "CoveragePoints", out cps);
return cps;
}
Note that the target state of the transition is irrelevant in this context; only
the bag of all the coverage points that were covered is relevant and is returned.
Action coverage. If you only care about covering the different actions, independent
of the start state, then you can use the following coverage function. If the
actions take no arguments then this coverage function is equivalent to the first
one above.
Bag GetActionCoverage(IState s, Action a)
{ return new Bag(a); }
State coverage. A widely used notion of behavioral coverage is to visit all the
different states of the state machine. You can implement a state coverage
function as follows. It is useful to map states to their hash codes here, rather
than keeping around full states as coverage points.
Bag GetStateCoverage(IState s, Action a)
{
int stateHash = model.GetTargetState(s, a).GetHashCode();
return new Bag(new Literal(stateHash));
}
206 Testing Systems with Complex State
Transition coverage. Another widely used notion of behavioral coverage is to
visit all the different transitions of the state machine.
Pages:
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278