Insights and outlooks on software development


Using TestDriven.NET efficiently

Sunday, December 9, 2007 by Thomas L

TestDriven.NET is an exceptionally good tool when you're working in a test driven fashion (you're doing that, aren't you?), but it's quite cumbersome having to reach for the mouse and rightclick in the editor whenever I want to run or rerun a test. Fortunately, it's possible to hook the TestDriven.NET RunTests action in Tools->Options inside Visual Studio. Do like this:

Under Tools->Options, Go to the Environemnt->Keyboard option. In the "Show commands containing", write TestDriven and then navigate to the RunTests command.


Then press the shortcut you wish to map to the command; in the screenshot above I've mapped it to Ctrl-F7, which I find works well, especially as the Start Without Debugger is mapped to Ctrl-F5. Then press Assign to map the keys to the command.

Now, the RunTests will function just as when you right-click and select Run Tests, i.e. the context in which the cursor sits is the basis for the tests to run. If the cursor is on the class level, all tests in the TestFixture are run, and if it's on method level, the specific Test is run. Quite nice, I find.

Do the same (with another key mapping, of course :) with TestDriven.NET.RerunTests and TestDriven.NET.Debugger. I've mapped them to Ctrl-Shift-F7 and LeftAlt-F7 respectively (for some reason, my VMware Fusion refuses to send the Ctrl-LeftAlt-F7, which I use at work, to my virtual Windows machine).

Using RerunTests I'm getting a quite nice Red-Green kind of workflow, writing a test, executing it and then I flip over to the class under test to fix, rerun, fix, rerun etc.

I hope you find TestDriven.NET as useful as I do. Right now, I can't live without it.

Filed under having  

0 kommentarer: