Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
F#运行NUnit测试_F#_Nunit - Fatal编程技术网

F#运行NUnit测试

F#运行NUnit测试,f#,nunit,F#,Nunit,我希望只运行一些单元测试,我已经将它们添加到了一个.fs文件中。我想在运行它们时从应用程序入口点调用它们 这是我写的测试 namespace InvoiceApp open System open NUnit.Framework open FsUnit module Test = let testPassed testName = printfn "Test Passed!! - %s" testName let testFailed testName = printfn "Test Fa

我希望只运行一些单元测试,我已经将它们添加到了一个.fs文件中。我想在运行它们时从应用程序入口点调用它们

这是我写的测试

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
namespace InvoiceApp
开放系统
打开NUnit.Framework
开放式FSU
模块测试=
让testPassed testName=printfn“Test Passed!!-%s”testName
让testFailed testName=printfn“测试失败!!-%s”testName
[]
类型测试()
[]
假设利润率为10%,总利润为200,预期为20``x y z()=
尝试
Math.percentage x y |>应等于z
测试通过“当利润率为10%,总利润率为200%,预期为20”
具有
| :? NUnit.Framework.AssertionException作为ex->
testFailed“当利润率为10%,总数为200时,预期为20”
打印“%s”例如消息

如何从另一个.fs文件的入口点调用这些测试?

看看
SimpleTestRunner
RemoteTestRunner
,阿拉巴马州。

不久前,我构建了一个NUnit测试运行程序作为一个F#模块,它应该支持您在命令行应用程序场景中的简单执行,请参阅

要设置它,只需包含此项并使用以下命令调用测试:

Tap.Run typeof<InvoiceApp.Test>
member test.``When profitmarging is 10% and total is 200 expect 20 `` (x:int,y:int,z:int) =