Search code examples
f#fsunit

Error on FsUnit example


I copied this example from the FsUnit project page:

open NUnit.Framework
open FsUnit
let [<Test>] trivial () = 1 |> should not (equal 2)

F# gives me the following error:

Error 2 This expression was expected to have type bool but here has type Constraints.EqualConstraint

Error 1 The type 'bool' is not compatible with the type 'Constraints.Constraint'

What am I doing wrong?


Solution

  • A newer version of FsUnit includes a change that renames the FsUnit.not function to FsUnit.not'. This should eliminate the conflict with the built-in not function. You can get the latest version from NuGet Gallery. Examples of use can be found on the FsUnit GitHub site.

    Let me know if you still see the issue. I'll be happy to do some more in-depth troubleshooting with you.