Unit Testing with VS Team System - A First Glance (Updated)
Visual Studio Team System for Developers has built-in unit testing functionality. Like most unit testing suites, it has a wizard that quickly generates testing stubs for all of the classes and methods in a project.
One of the more useful features of the unit testing tools is the automatically created wrapper classes. These wrapper classes use reflection to expose all of the underlying type's private methods. This de-encapsulation functionality makes testing the internals of a class much easier.
Unfortunately Microsoft didn't put as much thought into testing objects that implement the IDisposable pattern. None of the testing stubs wrap the target in a using block, meaning a lot of resources are potentially leaked. This is an especially aggravating when testing classes that hold onto unique resources like files.
Another issue with VS Team System is that it doesn't support sets of tests very well. Unlike MbUnit, it doesn't support calling the same test multiple times using different data. The developer or test engineer has to make a copy of the test routine for each set of inputs, possibly with the aid of a hand-rolled helper function.
Eric Smith has pointed out that there is a DataSourceAttribute that allows test inputs to be stored in a database.
If there are specific areas of VSTS or any other product you think we should have more coverage on, feel free to let me know.
P.S. I really like the code analysis features of VSTS.
I would like to see an in depth assessment of working with VSTS as a dev/test/build environment, particularly as it compares to the Subversion/CC.Net/NUnit/NAnt "standard" stack that many of us are used to. Maybe a comparison with JetBrains' new TeamCity stuff? It's the day-to-day usage I'm interested in rather than the headline "test stub generation is cool" stuff (test stub generation is not cool :-) ).
Personally, I see nothing really compelling in VSTS, but having never used it in anger I might be missing something important.
I'm not expert in the use of MbUnit to know if this is a valid comparison, but the Team System testing framework does have data-driven tests through the DataSourceAttribute. If you annotate a test method with that attribute, it will run the test for each row in the data source.
Christophe Achouiantz Mar 11, 2014