(Edit: Sorry for the misleading title. Indeed, this is more of an introduction to unit testing in 2005 then actual TDDing in it – Cory)
Over the weekend I got VS2005 beta installed on a virtual PC. While I know there have been a lot of changes to the IDE, I was most interested in the Testing features that were added to it. Here are some first impressions.
First, I fired up the IDE. I noticed that when I went to create a new Solution, I had the option of creating a Test Project:
Since I don’t normally start my projects, I filed that away. I decided to start with a Windows Application. After I created the solution, I added a Test Project to it, and ended up with something like:
After adding the Test Project, something really interesting happened. An AuthoringTests.txt file popped up, and it had instructions for how to get the tests up and running. About a minute later I had my first test written, which is the first test I usually use in my NUnit methods:
public void TestMethod1()
Assert.IsTrue(true, "This Works");
I noticed they also provide
Cleanup() methods (tagged by the custom attributes
[TestCleanup()] respectively). So it looked something like:
Great! Now how do I run it? The AuthoringTests readme said that tests could be run from the Test View window and the Test Manager window. Great. Where the heck is that? Ooh shiny new Test Menu option!
Zipping down to the Manage and Execute Tests option pulls up the Test Manager. From there, I was able to click on Run Tests, and get my first Green Bar (sorta)!
So I guess Green Checkies will have to do.
All in all, not a bad first start. The tests seem to take a little while to compile, but I am running it in a Virtual PC giving it 512MB of RAM, and it is Beta, so both of those together I’m sure have something to do with it. It was exciting seeing the work that went into it, going so far as to provide the AuthoringTests instructions. I don’t think I’m quite ready to replace NUnit with it, but it’s great to see some progress from Microsoft on the issue!
For those interested, according to the AuthoringTests.txt file, these are the Test Types you can create with Visual Studio Team Test:
Visual Studio Team Test allows you to create a number of different test types:
Generic test: A generic test is an existing program wrapped to function as a test in Visual Studio. Three examples of generic tests are the following:
– Wrap an existing test that adheres to the Visual Studio return-code interface.
– Wrap an existing test harness that adheres to the Visual Studio result-data interface.
– Wrap a general program to obtain specific functionality during a test scenario.
Manual test: The Manual Test type is used when the test tasks are to be completed by a test engineer as opposed to an automated script.
Ordered test: Use an ordered test to execute a set of tests in an order you specify.
Unit test: Use a unit test to create a programmatic test in C++, Visual C# or Visual Basic that exercises source code. A unit test calls the methods of a class, passing suitable parameters, and verifies that the returned value is what you expect.