Xunit: Assert.NotNull doesn't take a user message

Created on 8 Aug 2017  路  3Comments  路  Source: xunit/xunit

Most Assert methods takes an optional userMessage parameter, but Assert.Null and Assert.NotNull doesn't.

Most helpful comment

Thanks. I'll close this then. I do heavily disagree though. This isn't about self-documenting tests, but about daily test reports. You could have two of the same asserts in a test, and not know which one failed until you re-run the test. Getting a daily report with a more specific message about what failed, means you can often instantly assign it for triage to the correct person, because you know much better what exactly broke.

All 3 comments

Actually, you'll find only .True and .False take user messages. This is a purposeful choice, and not currently open for debate.

This is the definitive thread with our reasoning: https://github.com/xunit/xunit/issues/350

Thanks. I'll close this then. I do heavily disagree though. This isn't about self-documenting tests, but about daily test reports. You could have two of the same asserts in a test, and not know which one failed until you re-run the test. Getting a daily report with a more specific message about what failed, means you can often instantly assign it for triage to the correct person, because you know much better what exactly broke.

There is a solution if someone still needs it (https://stackoverflow.com/a/52973715/1143349).
I need it as I test localization resources and need to return the key which fails. If someone can explain why should I not add a key to the failed test message?

Was this page helpful?
0 / 5 - 0 ratings