BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Unit Testing with VS Team System - A First Glance (Updated)

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.

Correction

Eric Smith has pointed out that there is a DataSourceAttribute that allows test inputs to be stored in a database.

Rate this Article

Adoption
Style

BT