2015-02-23 175 views
1

我正在尋找只運行幾個單元測試,我已經將它們添加到.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測試?

回答

2

稍後我將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) =