With the release of TestDriven.Net version 2.16, you can now run your F# unit tests within Visual Studio. Prior to this version, I would execute my unit tests via NUnit-Gui, or xUnit's command line utility. Both tools are wonderful for handling unit tests, but like most, if not all programmers, I am lazy. I was getting very tired of switching windows. I even wrote my own small testing harness, here but I still had to fuss around with switching windows.I do realize that all it took was a simple keystroke combination of alt-tab, but waiting for my machine to re-paint the windows and the tools to re-load the new assembly became tiresome. To add to my laziness, in order to run my tests when in C#-ville, I assigned keystokes TestDriven.Net run tests method, I didn't even have to use the mouse! Resharper is another tool I use when I am programming in C#-ville, although Resharper has not yet made it way in to the F# world, there are still parts of the tool you can use. Consider the blank F# page, when you start a new project. All you get is:
#lightNot much here to get you started. So I created a ReSharper Live Template called "fixturef".
When I press the tab key, I get the following:
Wait, there's more!I also created another ReSharper Live Template, called "ftest":
By now, I know you're now asking yourself, "it can't possibly get any lazier", but oh yes, it can!
When I actually have to type some code to get a unit test ready to run, I got tired of having to reach the 10 inches for my mouse and perform a series of point-and-click operations. TestDriven.Net provides commands that you can assign keyboard shortcuts to. In Visual Studio, go to the options screen and select Keyboard. In the command name text box, start typing TestDriven. There are a series of commands to invoke TestDriven.Net. I assigned the ctl-alt-shift-T keystroke to the TestDriven.Net.RunTests command.
You get a nice message in the status bar of Visual Studio, letting you know the status of your test run.
Enjoy my laziness!