我已经建立了生成器类型,它生成三个的倍数。我想在Expecto的测试中使用它,如何注册生成器并告诉我的测试使用它?
let multipleOfThree n = n * 3
type ThreeGenerator =
static member ThreeMultiple() =
Arb.generate<NonNegativeInt>
|> Gen.map (fun (NonNegativeInt n) -> multipleOfThree n)
|> Gen.filter (fun n -> n > 0)
|> Arb.fromGen
我发现自己已经意识到了。用于在Expecto中注册生成器
let multipleOfThree =
{ FsCheckConfig.defaultConfig with
arbitrary = [ typeof<ThreeGenerator> ] }
并可以在您的测试中使用
testPropertyWithConfig multipleOfThree "test with your generator "
<| fun x -> Expect.equal (FunctionUnderTest x) "Expected" "Error message"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句