April 19, 2019
Hot Topics:

Frictionless Testing with TestDriven.NET

  • December 30, 2004
  • By Mike Gunderloy
  • Send Email »
  • More Articles »

But Wait, There's More!

So far, everything I've shown you could be done with any of the major unit testing frameworks, though TestDriven.NET makes it easier by keeping it all under one roof. But TestDriven.NET goes further to provide you with some advanced capabilities as well. For example, if a test fails, it adds an entry to the Visual Studio .NET task list. Double-clicking this entry takes you straight to the failing test. The "Run Test(s)" menu items is also integrated with Solution Explorer, so you can choose to run all the tests in a particular project or class easily.

TestDriven.NET also allows you to choose between in-proc and debugger testing with a simple menu selection. Normally, when you run your tests they just run, and you look to your actual code for problems. But what do you do when you suspect that the test itself might be in error? With TestDriven.NET, you set a breakpoint in the test and choose to run the tests in the debugger, as shown in Figure 3. When the test assembly hits the breakpoint, you can use all the regular debugging tools to figure out what might be wrong. This is possible in other unit testing tools (by attaching the debugger to the external process) but TestDriven.NET makes it a whole lot easier.

Choices for running tests

Two other features deserve mention as well. First, TestDriven.NET runs in its own process, which means that it's very unlikely to cause side effects with the code that it's testing. This also means that it can be stopped easily - in fact, when you're running tests, there's a Visual Studio .NET menu item to abort the rest of the test run. That's very useful when some test is taking much longer than expected. Second, you can run any method as an "ad-hoc test". Put the cursor inside it and choose to run tests, and you can see the output to the output pane. There are some limits to this facility (notably, there's no way to set input parameters), but it's a great way to experiment quickly with code.

About the Author

Mike Gunderloy is the author of over 20 books and numerous articles on development topics, and the lead developer for Larkware. Check out his latest book, Coder to Developer from Sybex. When he's not writing code, Mike putters in the garden on his farm in eastern Washington state.

Page 3 of 3

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date