-
Notifications
You must be signed in to change notification settings - Fork 731
Description
Description
When using fluent assertions for things like objects & lists, assertion failures will typically log the names of the variables. This doesn't appear to happen when comparing DateTimes, Guids, objects, etc.
It is very useful to have the variables names for context, as when the assertion message doesn't have these it is difficultto figure out which assertion failed when looking at test output for "AssertionScope" blocks (and for non-assertion scope blocks, you can only find the failing assertion via the line numbers in the stack).
Here is what the output looks like for one of the assertions which includes variables names:
var z = "SSSS";
z.Should().Contain("BBB");
> Expected z "SSSS" to contain "bbb".Complete minimal example reproducing the issue
var x = DateTime.UtcNow;
var y = DateTime.UtcNow.AddSeconds(1);
x.Should().Be(y);Expected behavior:
Assertion failure should be something like: Expected x to be <2020-07-15 16:51:43.1621939>, but was <2020-07-15 16:51:43.5991913>.
Actual behavior:
Expected date and time to be <2020-07-15 16:51:43.1621939>, but found <2020-07-15 16:51:43.5991913>.
Versions
- FluentAssertions 5.10.2
- .NET framework 4.8