I'm using F# to write my test methods but Nunit complains that the methods are non public.
namespace Test
open NUnit.Framework
type public Test() =
[<Test>]
let testIt () =
Assert.AreEqual(10,10)
what do I need to change?
Since let
bindings are private to the parent type, you have to use member
instead:
namespace Test
open NUnit.Framework
[<TestFixture>]
type public Test() =
[<Test>]
member x.testIt() =
Assert.AreEqual(10, 10)
If you don't need complicated setups, using module-level let
bindings directly should be preferable:
module Test
open NUnit.Framework
[<Test>]
let testIt() = Assert.AreEqual(10, 10)
You can put F# test cases in a module to make them public and visible to NUnit:
module Tests
open NUnit.Framework
let [<Test>] ``10 should equal 10`` () = Assert.AreEqual(10,10)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With