Tips, tricks and all the info about Microsoft Visual Studio 2008

Test Driven Development with Visual Studio 2008

, posted: 3-Feb-2009 09:00

[I feel this post needs a disclaimer here, this is not a post on Agile methodologies, but rather a post on how tools can be harnessed to aid you meet a more agile development life-cycle while using Visual Studio 2008.]

Agile software development has become quite the darling of the development community around the world. It promises to help teams create a product that gets to market quicker, has more value to customers or simply a project that's more fun to be part of.

This post is not about Agile development or the pros and cons of agile. What Agile means to different people can be subjective (that's both the beauty and the pitfall of the methodologies that call themselves Agile) and as such is best treated in a separate post.

Try the Agile Mainfesto as a starting point, then maybe try and read up on eXtreme Programming and Scrum to learn some of the more commonly understood methodologies.

Rather, I wanted to give some tips, some reviews and some exposure to the huge ecosystem of tools and techniques from Microsoft and also from the myriad of external developers, that make these techniques easier to follow.

Visual Studio 2008 is generally agreed to be one of the most feature complete, extensive IDEs for development available. From IntelliSense to built in easy debugging the power of Visual Studio 2008 is open for all to see. However there are a number of things that aren't quite as supported out of the box, but thanks to its great extensibility model (and the hard work of a number of developers) there are a myriad of tools out there to help you out.

I'll focus on two techniques made popular through agile development, Test Driven Development and Continuous Integration, and try and give some pointers as to how you can get into these techniques easily while using Visual Studio 2008.

Test Driven Development
Test Driven Development is one of the cornerstones of many of Agile development methodologies, and one that I personally try and practice (and preach) on all of my own projects. There are a number of tools out there to help you, but if you've never done TDD before the biggest piece of advice is to find someone who has and ask for a primer. Once you're ready to get going with TDD, you'll want to pick a testing framework, and the integration into your workflow and ease of use should be one of the considerations when picking the framework for your tests.

MS Test

If you're using the Professional or Team editions of Visual Studio you don't have to go very far. Support for Microsoft's home grown test framework MSTest is built right into the IDE. MSTest is a unit testing framework with a very similar syntax to NUnit, but it's only available built into the Pro and Team Suite Editions of Visual studio so you may need to find a 3rd Party solution if you're using standard or express editions of visual studio.

NUnit is the grand daddy of .Net unit testing frameworks, and probably the framework that most people will have heard of or used. NUnit itself comes with very little tooling to help you out from within Visual Studio but the stand alone runner and command line runner are a stalwart of many TDD practitioners

MbUnit was, for a long period of time, the only real alternative to NUnit. It still has one of the most active followings of all the unit testing frameworks out there. The syntax is very similar to NUnit and MSTest but has a number of other abilities that go beyond the other frameworks (although NUnit is catching up) RowTest was for a long time the reason someone would pick MbUnit over the others. MbUnit is also tied into Gallio, a test runner that will run tests in most frameworks, and the runner that I personally use on most of my projects. is a recent entry into the .net unit test framework world, and aimed to be more than just a Unit Testing framework. it's very opinionated (see Make Opinionated Software) and is probably one of the most real departures from the standard test frameworks listed above. The syntax and the style of writing tests are quite radically different. I strongly recommend reading why the designers of the framework made the decisions they did. At least to understand their beef with existing frameworks and why they felt a change was needed, even if you aren't intending to use itself. Another great way to integrate testing into your Visual Studio experience is with a tool called this lightweight tool gives you a context sensitive menu that allows you to run tests right from your code and report on test failures as errors. Well worth checking out. But test driven development is not about just the tests (many people who are used to TDD see TDD as less about the Testing and more about the Design). There are a number of things you will find that happen once you are familiar and running with TDD.

Get used to refactoring, it'll be here to stay for you if you run with an agile methodology. Even if you don't follow TDD you'll be wanting tools and techniques that allow you to quickly rewrite parts of your code as more requirements crop up and changes need to be made.

I personally recommend you try out tools such as ReSharper or Refactor! Pro both of these tools are a great aid to generating method stubs, increasing the power of Visual Studio IntelliSense and giving you guidance as to cleanly refactor your code and keep the impact of future changes low. ReSharper is my tool of choice simply because it used to be the front runner in terms of functionality, however that gap is closing if not non existent now and a lot of people swear by Refactor! Pro.

I don't know enough about Refactor! Pro to do it justice, i suggest you check out one of the many reviews that can be found using your search engine of choice. But I would advise getting one of these tools, your wrists will be happier from the reduced key strokes to get the job done. ReSharper also has a great in built test runner.


Continuous Integration
Continuous integration is another great tool to have under your belt. Basically going hand in hand with TDD to ensure that the code in your source repository is at a certain standard at any point in time. The first step to this is learning the build script language. Previously the only real choice was to learn Nant an xml language based on Ant. It's a very full featured build scripting language and can pretty much do anything you need it to do, from xcopy-ing to compiling to running tests and reporting on the results. However with Visual Studio 2008 there was a compelling case to learn the alternative build scripting language from Microsoft: MSBuild.

If you open up any of the .proj files within a Visual Studio 2008 project you'll be confronted with MSBuild. Visual Studio uses it as its own build language. All builds in VS2008 just use msbuild under the covers.

Why is this important? Simply put because you want your developers running the same builds as the build server so they can check things build before checking in (where errors become more about environment, forgotten files and simple oversight). If you get to grips with MSBuild you can get a build process together that runs both in VS2008 and on the build server itself. (You can do this with Nant too but takes a little more setting up) Once you've got to grips with a build script, you need a build server (which simply monitors your source repository for changes, checks out the code and runs a build, reporting on the results and notifying of failures), see more about CI here.

Team foundation server
Team Foundation Server  is Microsoft's fully featured build/source control/project management server. It's an all singing and all dancing solution that does great for integration into Visual Studio's workflow. however it can have a very unwieldily set-up process and can cost too much for smaller teams to justify.

TeamCity is a build server from JetBrains (makers of ReSharper). It has a very easy to set up configuration and can be used for building code in .net as well as many languages outside of .net. There's also a nice plug-in for Visual Studio that allows you to run a Personal Build (code isn't checked in until the build passes) and monitor results of other check-ins you've made to the code base. There's a free version that will allow you to run up to 20 build configurations.

There used to be a product called which was a port of CruiseControl to .net by Thoughtworks. however Thoughtworks now have a product called Cruise which is touted as a fully featured CruiseControl server. I've not used it myself so I'll refrain from giving it an inaccurate review. At the time of writing I couldn't get to the page however if it's still available is a heavily xml driven continuous integration server.

High on features, but also heavy on configuration. It's open source, free and has a strong community of users.

These are just a few tools that people who are looking to get into TDD and CI should look at. This is just the tip of the iceberg in terms of techniques and tools to go with.

I strongly recommend understanding the driving force behind Agile even if you aren't going down that route yourself. Read up on the Agile Mainfesto.

Learn what Scrum and eXtreme Programming are all about (along with Crystal Clear, Lean Development and the myriad of other agile methods).

I hope that the information above has piqued someone's interest and they want to take it further and read up on the tools and techniques mentioned. If not, or you feel somethings been missed feel free to leave a comment. The web is all about open discussions.

Download Visual Studio 2008 90 day trial
For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the Microsoft Visual Studio 2008 webpage.

About the Author

Owen Evans is a software developer and agile evangelist, currently working at Xero. He's a strong advocate for Behaviour Driven Development, and unit testing. You can find his blog here.

Other related posts:
The New Zealand ALM Conference 2011 (Application Life Cycle Management)
Writing your own Html Helpers for the ASP.NET MVC Framework
Automating Visual Studio 2008

About the Visual Studio 2008 Blog

In the years since the hugely successful release of Visual Studio 2005, Microsoft has used developer feedback from all over the world to introduce over 250 new features in the 2008 release.

This sponsored blog will bring Visual Studio 2008 tips and tricks from well known developers in the Australian and New Zealand tech community directly to you.

Make sure you bookmark this blog or subscribe to our RSS feed.

Other blog posts

The New Zealand ALM Conference...
Writing your own Html Helpers ...
Automating Visual Studio 2008...
Windows Azure Table Storage - ...
Windows Azure Table Storage - ...
XML and XSLT in Visual Studio ...
Introduction to New SQL Server...
Using the Visual Studio 2008 P...
Getting started with Windows A...
Why consider sitting for an MC...

Some recent comments

Praveen M on Visual Studio 2008 support for building SilverLigh: I installed SILVERLIGHT TOOLS for VS2008 at my work. I am able to do silverlight...

zefo on Unit testing with Visual Studio 2008: Just minor recommendation: better use *.png for the screenshots. Jpeg is more su...

gil ziny on Unit testing with Visual Studio 2008: When I associate the unit test with TFS testing policy, if fails during check-in...

lynette on Visual Studio 2008 JavaScript Debugging: i have enable in IE the ability to debug scripts. if i go to my section in my c...

Junkie on Why consider sitting for an MCTS or MCP Certificat: The way you presented the case for certification has been completely different f...

Brian Link on Unit testing with Visual Studio 2008: You seem to be incorrect in one of your opening remarks - it seems that web.conf...

Dipanwaya on Unit testing .Net Compact Framework applications w: Steps Behind the Test in the VS 2008? How to test a module in the VS 2008 Envir...

Ricardo on Visual Studio 2008 support for building SilverLigh: Yes! Found the solution myself :) Reset the environment of Visual Web Developer...

Ricardo on Visual Studio 2008 support for building SilverLigh: Have the same problem after installing Visual Web Developer 2008 SP1 and Silverl...

kjward on Automating Visual Studio 2008: thanks lots for all the great info. i'm sure the answer to my question is in th...


The Visual Studio 2008 blog is sponsored by Microsoft NZ. The blog posts are the authors' genuine accounts of their experiences with Visual Studio 2008 and are not influenced or filtered by Microsoft NZ in any way.