2015-02-11 134 views
0

我正在与VS 2013,F#NUnit一起工作。值得注意的是我是F#的新手。F#NUnit测试返回为未运行

我添加了非常基本的测试,并且当我将调试器附加到NUnit并在调试模式下运行时,断点正在被击中,但是测试回来,因为没有运行。 NUnit将其标识为测试但不运行(假设)Assert(可在底部截图中看到)。

enter image description here

enter image description here

测试:

module Test 
open NUnit.Framework 

[<TestFixture>] 
type Test() = 
    [<Test>] 
    let ConcatinationTest = 
     Assert.AreEqual(Implementation.Concat("aaa"), "rootaaa") 
     |> ignore 

实现:

module Implementation 

let Concat(text:string) = 
    "root"+ text 

我的预期一定是错误的。为什么它不起作用?

+4

你将它定义为一个值,但它必须是一个方法:'静态成员ConcatinationTest()= ...' – bytebuster 2015-02-11 17:22:04

+0

@bytebuster嗨,它做到了。你可以将它作为答案发布吗?谢谢。 – 2015-02-12 09:23:06

回答

1

你将它定义为一个值,但它必须是一个方法:

[<Test>] 
static member ConcatinationTest() = ... 

(根据OP的要求将注释转换为答案)

1

OP在这里,为那些想知道这个作品的人。

module Test 
open NUnit.Framework 

[<TestFixture>] 
type Test() = 
    member this.ConcatinationTestData() = 
     [new TestCaseData("roottext","text"); new TestCaseData("root","")] 
    [<Test>] 
    [<TestCaseSource("ConcatinationTestData")>] 
    static member ConcatinationTest(expected:string, text:string) = 
     Assert.AreEqual(expected,Implementation.Concat(text)) 
     |> ignore 

调试 - >附加到过程 - > NUnit的-agent.exe

结果: enter image description here