F#运行NUnit测试
问题描述:
我正在寻找只运行几个单元测试,我已经将它们添加到.fs文件中。我想从应用程序入口点调用它们,当我想运行它们时。F#运行NUnit测试
这我已经写
namespace InvoiceApp
open System
open NUnit.Framework
open FsUnit
module Test =
let testPassed testName = printfn "Test Passed!! - %s" testName
let testFailed testName = printfn "Test Failed!! - %s" testName
[<TestFixture>]
type Test() =
[<TestCase(200,10,20)>]
let ``When profitmarging is 10% and total is 200 expect 20 `` x y z() =
try
Math.percentage x y |> should equal z
testPassed "When profitmarging is 10% and total is 200 expect 20"
with
| :? NUnit.Framework.AssertionException as ex ->
testFailed "When profitmarging is 10% and total is 200 expect 20"
printfn "%s" ex.Message
我怎样才能调用从入口点这些测试在不同的文件中.FS测试?
答
稍后我将NUnit测试运行器构建为F#模块,它应该支持您在命令行应用场景中的简单执行,请参阅Running TAP。
要对其进行设置,只需包含此F# snippet和调用与测试:
Tap.Run typeof<InvoiceApp.Test>
注意:您还需要改变测试用例是一个成员函数,并使用非通用tupled参数对于NUnit的内置亚军或TAP亚军来说,看到它,即
member test.``When profitmarging is 10% and total is 200 expect 20 `` (x:int,y:int,z:int) =