Professional Visual Studio 2005 Team System (Programmer to Programmer)

Visual Studio Team System offers a new project template called "Test Project." Projects of this type provide a convenient way to store tests of any kind. You may decide to have all of the tests in your test project be of one type, or you may mix different types of tests within the same test project.

The types of tests that can be contained in a test project include the following:

Placing your tests in a test project has the additional benefit of keeping them separate from your implementation code, reducing the risk that you'll accidentally deploy test code to your production environment.

Later in this chapter, we'll describe test management in detail, including use of the Test Manager and test lists to organize and execute collections of tests.

Creating a test project

There are a number of ways to create a new test project. You can create a test project before you create any tests or you can create one as you are creating a new test.

To create a test project before creating any tests, you can right-click on an existing solution and choose Add image from book New Project. You may instead use the File menu, also selecting Add New Project. You will see the Add New Project dialog, as shown in Figure 13-1.

Figure 13-1

Under Project Types, choose the Test category under the language you wish to use for your tests, if applicable. Select Test Project from the Templates list and assign a name to your project. If you do not already have a solution, you will be able to create one as well.

When creating tests, Visual Studio will offer to automatically create a test project for you if you do not already have one. We discuss this later in the chapter.

When your test project is created, Visual Studio adds two files to your solution's Solution Items folder. One is the test run configuration, an XML file named localtestrun.testrunconfig. This file contains the various settings that determine how your tests will be executed. You can double-click on this file to display those settings. We'll cover test run configuration settings throughout the next few chapters.

The other file, known as the test meta-data file, is also XML-based and is named <ProjectName=.vsmdi. This file stores information about your solution's test lists and links to any contained tests. Double-clicking this file will open Test Manager. We'll discuss the use of this file later in this chapter.

Setting test project options

You may notice that the test project you have created is not empty. By default, a number of files will be included with your new test project. These include an "About Test Projects" text file that introduces test projects as well as sample unit and manual tests. These serve as helpful starting points to add your tests, but you can safely delete these if you choose. To change what types of files are added to a new test project, select Tools Options. On the resulting Options dialog, expand the Test Tools category and select Test Project. You will see options as shown in Figure 13-2.

Figure 13-2

You may set the default language for new test projects using the drop-down list at the top. This setting will save you some time later, as you will not need to choose the language each time you create a new test project, though you always have the option to override this setting.

Below that, you will see a list of file types organized by test project language. Notice that several file types are already selected for you. The types of files that are automatically included can be specified by language type. For example, you may wish that VB.NET test projects are always created empty, while your C# test projects include the "About Test Projects" help file. Select which files you wish included, if any, and press OK.

Категории