fsprojects / FsUnit

FsUnit makes unit-testing with F# more enjoyable. It adds a special syntax to your favorite .NET testing framework.

Home Page:http://fsprojects.github.io/FsUnit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent behaviour of `should equal` in NUnit vs XUnit

Smaug123 opened this issue · comments

Description

See #203 (comment).

This test behaves differently in xUnit vs NUnit:

    [<Fact>]
    member __.``should pass when Equals returns true``() =
        anObj |> should equal (box(new AlwaysEqual()))

(On master, that test is not present in the Xunit tests, but it is present in the NUnit tests.)

In xUnit, a |> should equal b ultimately (via the CustomMatcher) asks whether a = b; that is, whether a.Equals(b).

In NUnit, a |> should equal b asks whether a Equality.IsEqualTo(b), which boils down to Is.EqualTo(b), which NUnit interprets as _.AreEqual(b, a), which ultimately asks whether b.Equals(a).

The semantics of the equal CustomMatcher we define for XUnit are therefore not the same as the semantics of NUnit.

Known workarounds

None; the semantics of the XUnit CustomMatcher.equal (which we do control) are different from the semantics of the NUnit equal constraint (which we don't control; we just hand it off to NUnit).

Could you please confirm, using the test I put in the description, that this problem is fixed? I'm away from my computer, but I strongly suspect it is not.