如何将配置应用于一套基于 属性 的测试?
How do I apply a configuration to a suite of property-based tests?
如何将配置应用于一套基于 属性 的测试?
我尝试了以下方法:
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`` () =
...
但是,Config
成员设置为私有,不会编译。
有什么建议吗?
如果要将 MaxTest
设置为 10000
,请使用 MaxTest
属性:
[<Property(MaxTest = 10000, QuietOnSuccess = true)>]
let ``my property-based test`` () =
// ...
如果您认为这违反了必须为每个 属性 键入的 DRY 原则,您可以创建一个派生属性:
type MyPropertyAttribute() =
inherit PropertyAttribute(
MaxTest = 10000,
QuietOnSuccess = true)
然后在您的属性上使用该属性:
[<MyProperty>]
let ``my property-based test`` () =
// ...
如何将配置应用于一套基于 属性 的测试?
我尝试了以下方法:
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`` () =
...
但是,Config
成员设置为私有,不会编译。
有什么建议吗?
如果要将 MaxTest
设置为 10000
,请使用 MaxTest
属性:
[<Property(MaxTest = 10000, QuietOnSuccess = true)>]
let ``my property-based test`` () =
// ...
如果您认为这违反了必须为每个 属性 键入的 DRY 原则,您可以创建一个派生属性:
type MyPropertyAttribute() =
inherit PropertyAttribute(
MaxTest = 10000,
QuietOnSuccess = true)
然后在您的属性上使用该属性:
[<MyProperty>]
let ``my property-based test`` () =
// ...