BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

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

by Jonathan Allen on Oct 20, 2006 |

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.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

... by Jim Arnold

That's a pretty quick first glance. Was the rest of the article cut off? Do you have anything positive to say about VSTS?

Re: ... by Jonathan Allen

This was just first impressions based on using the product against production code for a few hours. As I hear more from people actually using VSTS, more in-depth coverage will be forthcoming.

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.

Jonathan Allen
Jonathan@InfoQ.com

P.S. I really like the code analysis features of VSTS.

Re: ... by Jim Arnold

(On reflection, my first post was a little rude. I apologise).

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.

Jim

Data-Driven Tests by Eric Smith

"Unlike MbUnit, it doesn't support calling the same test multiple times using different data."

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.

Re: ... by Jonathan Allen

That sounds like a great idea. It will take some time, but we'll see what we can do.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

5 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT