Reputation: 13983
Here's the example of model-based test in FsCheck:
let spec =
let inc = { new Command<Counter, int>() with
override __.RunActual counter = counter.Inc(); counter
override __.RunModel m = m + 1
override __.Post(counter, m) = counter.Get = m |@ sprintf "model: %i <> %A" m counter
override __.ToString() = "inc" }
let dec = { new Command<Counter, int>() with
override __.RunActual counter = counter.Dec(); counter
override __.RunModel m = m - 1
override __.Post(counter, m) = counter.Get = m |@ sprintf "model: %i <> %A" m counter
override __.ToString() = "dec" }
{ new ICommandGenerator<Counter,int> with
member __.InitialActual = Counter()
member __.InitialModel = 0
member __.Next model = Gen.elements [inc;dec] }
How do I disable shrinking of commands for this test?
Upvotes: 1
Views: 90
Reputation: 17038
If you want to prevent FsCheck from shrinking the number of commands used (see my question above), you can convert the spec to a property that disables shrinking:
let property =
let generator = Command.generate spec
let shrinker _ = Seq.empty // disable
Command.toPropertyWith spec generator shrinker
Check.Quick(property)
This allows FsCheck to generate command sequences that are longer than necessary. E.g. [inc; inc; dec; inc; inc; dec; dec; dec]
.
Upvotes: 1