FsUnit icon indicating copy to clipboard operation
FsUnit copied to clipboard

Testing lists for equality gives unpleasant failure report

Open snuup opened this issue 1 year ago • 4 comments

[ 77 ] |> shouldEqual [ 99 ]

reports the failure

Unhandled exception. NUnit.Framework.AssertionException: Assert.That(, ) Expected: < 99 > or < 99 > But was: < 77 >

This is caused by this tricky code in Equality.fs:

static member inline IsEqualTo(x: 'T) =
    match (box x) with
    | :? IStructuralEquatable -> Is.EqualTo(x).Or.EqualTo(x).Using<'T>(Equality.Structural)
    | :? IStructuralComparable -> Is.EqualTo(x).Or.EqualTo(x).Using<'T>(Equality.StructuralC)
    | _ -> Is.EqualTo(x)

(I did not succeed fixing this, removing the Or constraints leads to no detailed list comparison.)

snuup avatar Feb 23 '24 15:02 snuup

Hi @snuup, I'm looking into it.

CaptnCodr avatar Feb 23 '24 19:02 CaptnCodr

Hi @snuup, I found out that this is the most precise code regarding the failure message. The message blocks changed slightly since NUnit v4.

CaptnCodr avatar Mar 01 '24 10:03 CaptnCodr

Thx for your efforts. From a user perspective the message is irritating. Certainly not a show stopper, more a somewhat serious cosmetic issue.

snuup avatar Mar 09 '24 21:03 snuup

Yea, I let this open here. Perhaps, someone/I find a way to change this.

CaptnCodr avatar Mar 09 '24 22:03 CaptnCodr