2 Comments

  • I find that I use the explanatory messages less and less.



    If I use great names for my tests (as you recommend in an earlier article), the test name usually tells me everything I need to know about the failure.



    The only time I need explanatory messages is when I have multiple assertions in one test method. But that violates another of your excellent articles (about testing only one thing).



    As I make each test test only one thing, I need multiple assertions less and less. And as I write great names for tests, the explanatory messages become redundant.

  • I also find myself using messages in asserts less and less.



    I find the use of the messages in asserts to be a subtle form of duplication. As tests & code get refactored the messages tend not get updated and over time the messages become misleading. The test name/method name is usually enough.



Comments have been disabled for this content.