我已经建立了我的发电机类型,生成三倍的倍数。我想把它用在与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发布于 2020-07-13 08:42:52
我找到了答案就是我自己。在Expecto注册您的生成器
let multipleOfThree =
{ FsCheckConfig.defaultConfig with
arbitrary = [ typeof<ThreeGenerator> ] }可以在你的测试中使用
testPropertyWithConfig multipleOfThree "test with your generator "
<| fun x -> Expect.equal (FunctionUnderTest x) "Expected" "Error message"https://stackoverflow.com/questions/62834756
复制相似问题