erichexter / Should

Should Assertion Library
Other
141 stars 29 forks source link

Failed assertions message formatting #13

Open skajfes opened 7 years ago

skajfes commented 7 years ago

Can message formatting be simplified to clear up some unecessary noise from the messages themselves, or at least to organise the message in a way that the most useful info is at the top?

For example ShouldEqual() exception returns a message like this:

Should.Core.Exceptions.EqualException : Assert.Equal() Failure Expected: 2 Actual: 1

I would like to change the message to be something like this:

Expected: 2 Actual: 1 Assert.Equal() Failure

Or whatever else that the first line of the message includes the most useful info. The reason I ask this is because ReSharper test runner displays the first line of the message in the test list, and it is useful to show the failure inline.

This image shows the ReSharper test runner examples. First two tests are using Nunit assertions and it is immediatelly clear what the expected result was, no extra noise. The third test is using Should assertions, and only thing that is clear is that there was an equalilty failure with a lot of verbosity and noise.

image

I can create a pull request with the required changes, but wanted to check if this is something plausible to be considered as part of the project, and to see if there are more suggestions.