What should you write in a test Assert message?

My blog has moved. You can view this post at the following address: http://www.osherove.com/blog/2005/4/10/what-should-you-write-in-a-test-assert-message.html
Published Monday, April 11, 2005 1:50 AM by RoyOsherove

Comments

Sunday, April 10, 2005 11:26 PM by TrackBack

# New Team System Stuff - 2005-04-11

Visual Studio Team System

Richard Campbell has announced that he and Carl Franklin will tape an episode...
Thursday, April 14, 2005 8:43 PM by Dale Emery

# re: What should you write in a test Assert message?

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.
Thursday, April 14, 2005 9:56 PM by Andy Sipe

# re: What should you write in a test Assert message?

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.

Thursday, April 21, 2005 10:18 PM by TrackBack

# New Team System Stuff - 2005-04-11

Friday, June 01, 2007 12:56 PM by Gary Sherman

# Elevating consulting-ware

Back when I was working at Clarify, a good chunk of my time was spent doing custom development work,