In case you hadn't already heard, the testing tools that were previously only available in the Team System edition of Visual Studio are included in Visual Studio 2008! This is great news for those using Nunit because they couldn't afford the Team System editions. Unlike Nunit, these tools full integrate with the IDE!
So, let's have a look. I opened up one of my existing projects, and in the context menu there's a new option for "Create Unit Tests".
If you click this option, you'll be presented with a list of your classes and their methods. You can tick those you wish to generate unit tests for.
The settings dialog allows you to set how the class and method names are generated.
Tests will automatically be generated in a new project, so when you click Ok, you'll be prompted for a name. I'm not entirely sure why this wasn't just included on the previous dialog, but it's not a problem.
Now your tests will be generated. It may take a few minutes - it took a while here, and I only had one test to generate! When finished, you'll see a new project in your solution explorer, and some config files in a new "Solution Items" folder.
In the generated tests is a property of type TestContext. I've never used anything similar in Nunit, but it looks like this allows data-driven tests, where you can have a single test run for every row in a set of data you provide. I can see this being very powerful for testing lots of different conditions without duplicating tests!
To run your tests, you can use the new Tests menu at the top of the window. You'll get build-like progress, and failing tests show similar to compile errors. Double-clicking a failed test will give details, as shown below.
While I love Nunit, I've been annoyed there's been no real (free) integration of tests into Visual Studio, so I'm made up to finally have these testing tools at my fingertips. Move over Nunit, Microsoft are taking over!
The more I use Visual Studio 2008, the more I wish I was using it at work! It's packed with new features that make coding much quicker and less error-prone!
Don't forget, there are also free versions of Visual Studio 2008 (sadly without testing tools!) for the home-coder on a budget!