Monday, May 29, 2006
If you do test driven development, chances are that you have a standard folder structure that is generated by a nant script, it probably looks something like this:

Inside your src folder are you app and test directories. All of your test projects are placed in the test directory and all of your application source code is placed in the app directory.

Knowing that this is the case, we can easily set up a project template using Visual Studio 2005 to create our test projects for us. In the end we won't have to keep deleting the nasty class1.cs file that Visual Studio creates for us and we also won't have to constantly add references to external tools that we may be using for testing purposes (NUnit, RhinoMocks, etc.).

The first thing you need to do to setup your project template is to create an empty class library project in your src/test directory using visual studio 2005.

Next delete class1.cs, you will now have an empty class library, this by itself isn't very interesting but we know that we have a Nant script that will generate our default folder structure for us. Knowing this, we can create a project that will reference our testing tools relative from our src/test directories.

To do this, right click your testing project and select "add reference", navigate to your tools directory and add references to NUnit, RhinoMocks and any other 3rd party tools you would like to use.

Now, in Visual Studio 2005 select "File->Export Template" and export your testing project template. Select the wizard defaults until the finish button, a folder now opens up with your testing project template. Close the folder as it is just showing you the user created templates you already have.

The next time you need a testing project, your testing project template will be available to you in VS2005. All you have to do is right click you solution and select "Add New Project" you will then notice that your testing project template is available to you.




Notice that now we have an optimal testing project, even if we start a new project or a new solution, the project template we just created will look at the tools directory, this is works great since your Nant script should always generate the same folder stucture. We can now resume our regularily scheduled testing.
Monday, May 29, 2006 3:34:33 AM (GMT Standard Time, UTC+00:00)  #    Comments [3]  | 

Theme design by Jelle Druyts

Pick a theme: