Reviews
Unit testing for .NET gets even easier
- By Mike Gunderloy
- December 23, 2004
TestDriven.NET
Free (registration required
www.testdriven.net
I've written at length about the benefits of unit testing and test-driven
development in the past, so I'll try not to repeat myself here. Basically, the
idea is that you should write a test for every bit of functionality in your
application, and exercise these tests as you go along to make sure that you
didn't break anything. Proper use of these techniques can lead to increased
confidence and fewer errors in your code.
The last few times I've looked at unit testing tools for .NET, they've all
run as external processes. Using reflection, these tools can look into a .NET
assembly and ferret out all of the test classes and methods (marked by special
attributes), run them, and report on the results. But TestDriven.NET breaks this
mold by actually running inside of Visual Studio .NET. Running a unit
test is as simple as right-clicking and choosing "Run Test(s)". By implementing
this choice on every level from the solution down to individual methods,
TestDriven.NET lets you choose precisely which tests to run at any given
time.
TestDriven.NET also doesn't try to reinvent the wheel, or in this case, the
unit testing framework. Instead, it works with a number of popular frameworks:
NUnit, MbUnit, and even (for
those of you brave enough to run the Visual Studio 2005 beta) Microsoft Team
System. It even comes bundled with a copy of MbUnit so you don't have to
download and install additional software to get going.
If all the tests succeed, you get a line of output in the IDE and keep going.
If anything fails, you still get the full output in the IDE, but you also get a
task in the task list telling you to fix the darned thing. Of course,
double-clicking the task takes you straight to the failing line of test code.
TestDriven.NET also adds some additional flexibility to testing. One nice touch
is that you can use the debugger to run tests, which provides an easy solution
for stepping into test code - something that's a nuisance with an external
tool.
Overall, TestDriven.NET makes unit testing just a tiny bit easier - which of
course makes it a tiny bit more likely to happen. I miss the nice
red/yellow/green display of the external tools, but overall this is a big
improvement. I'd rate this one of the best freeware .NET applications for
developers around.
About the Author
Mike Gunderloy has been developing software for a quarter-century now, and writing about it for nearly as long. He walked away from a .NET development career in 2006 and has been a happy Rails user ever since. Mike blogs at A Fresh Cup.