Fluentassertions: Content of Test Fail message includes member name?

Created on 10 Nov 2016  路  3Comments  路  Source: fluentassertions/fluentassertions

Maybe I dreamed this whole thing, but I could swear that the last time I used FluentAssertions, if I did something like this:

myobject.myMember.Should().Be("Hello");

If the assertion failed, I would get a really useful message like "Expected myMember to be "Hello"

But today, I'm just getting "Expected string to be "Hello".

Did I just imagine that, or is FluentAssertions supposed to include the member name in its error messages?

future

Most helpful comment

Bummer. Would be a really awesome feature -- would eliminate a lot of the "because" clauses

All 3 comments

Sorry, wrong framework. Althought it is something I'm considering for #463

Bummer. Would be a really awesome feature -- would eliminate a lot of the "because" clauses

This is fixed with #588 which will be a part of the upcoming 5.0.0.

The failure message will now be:

Expected myobject.MyMember to be "Hello" with a length of 5, but "Hello!" has a length of 6.

Note that for this to work, your test needs to:

  • target full .net framework or .netcore 2.0
  • be build in debug mode (https://github.com/fluentassertions/fluentassertions/issues/588#issuecomment-355765033)
Was this page helpful?
0 / 5 - 0 ratings