I am looking to just run a few unit tests, I have added them them in an .fs file. I want to call them from the applications entry point as and when when I want to run them.
This the test I have written
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
How can I call these tests from the entry point in a different .fs file?
A little while back I built an NUnit test runner as an F# module which should support your simple execution in a command line app scenario, see Running TAP .
To set it up, simply include this F# snippet and invoke the tests with:
Tap.Run typeof<InvoiceApp.Test>
Note: you will also need to change the test case to be a member function and use a non-generic tupled argument for either NUnit's built-in runner or the TAP runner to see it, ie
member test.``When profitmarging is 10% and total is 200 expect 20 `` (x:int,y:int,z:int) =
看看SimpleTestRunner
和RemoteTestRunner
, 这个问题 。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.