views:

79

answers:

2

Using Visual Studio 2008 for a unit test, one of the unit tests has to do with a basic performance smoke test to make sure additional code doesn't slow down a heavily-used method too badly.

Obviously, I want this to fail when the "# per second" falls below a certain value, and of course it displays my message in the Error Message column, but when it passes, I'd still like this performance metric displayed somewhere in the Unit Test results.

Is this possible?

+1  A: 

You could just print the value to standard output (Console.WriteLine). It is very low tech, but standard output is usually captured.

Of course, it all depends on how you display your Unit Test Results. Most of the time results are just Red/Green, with error details shown...

Nader Shirazie
I would stay away from Console.WriteLine, because if you were to have CC.NET run your unit tests it will barf on any Console.WriteLine
Lucas B
We use CC.NET, and console out is indeed captured, and no, it doesn't barf. Sometimes I wish we didn't have so much output...
Nader Shirazie
Sorry I didn't mean barf, it will throw an exception in the window. Fortunately it continues, but it is confusing if you have other issues.
Lucas B
Again, don't see why writing to the console causes a problem -- its just a way to access standard output, which isn't a problem.
Nader Shirazie
+1  A: 

You could use NUnit, it has the Pass utility which allows you to record a message in the test result for instances like this.

Lucas B
When using Assert.IsTrue, the message will only be there if the Assertion Fails. That's the problem the OP has.
Nader Shirazie
Assert.Pass does look promising though
Nader Shirazie