oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Unit Testing in .NET Projects
Pages: 1, 2, 3, 4, 5

VSTS and the VS IDE

VSTS enjoys a close relationship with the VS IDE, which you would expect from a Microsoft tool. The IDE allows you to use a wizard to generate the unit tests from the code you are testing. This supports testing both public and private methods; however, opinion about testing private methods remains divided. VSTS includes TestManager, which is a GUI to allow you to select tests to run and to see the results of those tests. TestManager allows you to run all of your unit tests at once, or you can select which tests you want to run. You can also add additional information to a test, such as adding the DataSource attribute that we featured in the example. Finally, VSTS supports debugging unit tests in the VS IDE, so that it's possible to set breakpoints and start debug run via your unit test.


VSTS supports running its test types (including unit tests) via a command-line tool called MSTest. MSTest does require VSTS to be installed to work (client side tools) and is not available individually for set up on a build server, etc.


VSTS unit tests can be run in a build cycle using an extended version of MSBuild called TeamBuild.

Other Notes

You need to be a MSDN subscriber to download CTP releases; beta 2 can be downloaded from MSDN or you can receive it in the mail for a small charge.


This product is not a unit testing framework, but a Visual Studio add-in for integrating existing unit testing frameworks into the IDE. It offers test execution from the IDE, both in and out of the debugger. It currently supports all versions of VS.NET and the unit testing frameworks NUnit, MbUnit, and MS Team System. Test execution can begin from several actions. Right-clicking (in a test method, in a class test fixture, in a namespace, on the solution, on a project, or on a class) will expose the Run Test(s) context menu item. This context menu item will begin executing the test(s). There is a feature called Ad-Hoc testing that relates to Run Test(s) context menu. If you right-click in a method that is not part of a test fixture class and run it as a test, the method will in effect become sub-main. If there is a return value from the method, it will be displayed in the output pane. Regular tests results are printed to the output pane as well. If there is an exception and the line numbers are available, they are active and can be double-clicked to navigate to that line. Task list entries are created for failing lists as well.


I don't see a benefit to pitting these products against each other. They each serve different needs. NUnit provides the basics needed for unit testing in a clean and elegant fashion. It has been integrated into many other products and adopted as standard by the .NET community. MbUnit is an advanced unit testing framework. It has been integrated into almost as many products as NUnit. MbUnit's motivation is to provide a more robust framework, taking on more of the common unit testing tasks so that you don't have to. VSTS has an entirely different goal. This product was born from a desire to integrate into the process of creating software. Not only does it provide a basic unit testing framework, but it integrates into the IDE. Its integration into the IDE is for the purpose of injecting itself before a developer can submit to source control. It can impose itself on a developer and force unit testing into the process. TestDriven.NET has its own motivations. It lowers the effort required to run tests. If I don't have to leave the IDE to run a test, if I can begin debugging a test with a single click, I am more likely to write more tests. It makes it easier for me to do the right thing. That is the criteria by which I would urge you to judge which of these products is right for you and or your team. Which one will make it easiest for you to do the right thing?


Jay Flowers is a .NET developer working as a design lead at Northrop Grumman.

Andrew Stopford hails from Manchester, UK and is a .NET Developer with the Mobile & Wireless Group.

Return to