我一直坚持单元测试。我有以下源代码:
module SampleTest
open FsUnit
open NUnit.Framework
[<TestFixture>]
[<Category("Category name")>]
type DoSthTest() =
let mutable state = []
[<SetUp>]
member public x.``run before test``() =
state = []
[<Test>]
member x.``add item``() =
state <- List.append state [1]
state.Length |> should equal 1
一般来说,它运行良好....但没有 [] 功能。我收到以下异常:结果消息:SetUp 或 TearDown 方法的签名无效:在测试前运行
有人知道为什么吗?第二个问题是:是否可以编写一个没有类型定义但 SetUp 也可以工作的单元测试?我的意思是这样的:
module SampleTest
open FsUnit
open NUnit.Framework
let mutable state = []
[<SetUp>]
let ``run before test``() =
state = []
[<Test>]
let ``add item``() =
state <- List.append state [1]
state.Length |> should equal 1
我又遇到了和以前一样的异常