2

How do I apply a configuration to a suite of property-based tests?

I tried the following:

let config = { Config.Quick with MaxTest = 10000
                                 QuietOnSuccess = true }

[<Property(Config=config)>] // Doesn't work because "Config" is a private member
let ``my property-based test`` () =
   ...

However, the Config member is set to private and will not compile.

Any suggestions?

Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
Scott Nimrod
  • 11,206
  • 11
  • 54
  • 118

1 Answers1

4

If you want to set MaxTest to 10000, use the MaxTest property:

[<Property(MaxTest = 10000, QuietOnSuccess = true)>]
let ``my property-based test`` () =
   // ...

If you feel that this violates the DRY principle to have to type that for every property, you can create a derived attribute:

type MyPropertyAttribute() =
    inherit PropertyAttribute(
        MaxTest = 10000,
        QuietOnSuccess = true)

and then use that attribute on your properties instead:

[<MyProperty>]
let ``my property-based test`` () =
   // ...
Mark Seemann
  • 225,310
  • 48
  • 427
  • 736