Recently I was playing with FluentAssertions library. I was really amazed by the beautiful error messages generated by FluentAssertions. For example, for this failing test:
FluentAssertions generates a message:
Unfortunatelly my joy did not last long. When I added an explanation to an assertion and broke the line because it got too long:
FluentAssertions reproted just:
It turns out, in order to have these fancy error messages,
we must place
.Should() on the same line as the
The above test generates a message:
Notice that comment was also include in the message.
This behavior of FluentAssertions really suprised me. Why the way we format our code have influence over the readability of error messages?
Anyway this is how FluentAssertions works, moreover this behaviour is described (with short explanation how it works) on the first page of the official documentation. If only I have spend ten minutes reading the friendly docs instead of skimming it…
From now on I will follow “Read The Friendly Manual” (RTFM) advice!!!