Custom format for assertion exception messages #2218
Replies: 2 comments 2 replies
-
|
No, unfortunately not. The "because" part is part of a hard-coded template that is specific for every assertion. |
Beta Was this translation helpful? Give feedback.
-
|
I agree with the OP, sometimes it can be useful to provide some context around the failure to assist the dev, but it doesn't make sense to provide it in the or use FailWith : With Neither are particularly neat when used to working with the fluent experience ;-) I feel that this could be a lot neater if it was handled in the API e.g. could you add an additional optional param - failedBecause : |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to customize the format of the exception messages? In particular I would like to move the "because" clause to the end.
I get a lot of failed tests with messages that look like this:
but I feel they would read much more naturally like this:
Sometimes it's really hard to craft good, concise "should succeed because" clause to explain why an assertion is true, but it's very easy to to automatically have a concise, helpful message that "but failed because" clause. A format with the "because" at the end would read well in either case.
Beta Was this translation helpful? Give feedback.
All reactions