Export (0) Print
Expand All

How to: Create a Test Project

Test projects can contain tests of any type. You can create a test project explicitly. Or, if your solution contains no test projects when you create your first test, a test project is created automatically and the test is placed in it.

Before you create a test project, you may choose to configure the way test projects are created. This means determining how many tests and what kinds of tests are automatically added to new test projects, in addition to the default language of the test project. To do this, you use the Options dialog box, which is available on the Tools menu. For more information, see How to: Configure Test Project Creation.

As described in the following procedures, you can create test projects in several ways:

Create a test project when you add a test

  1. Click Test and then click New Test.

    The Add New Test dialog box is displayed.

  2. Under Add to Test Project, choose one of the options for creating a new test project. For example, click Create a new Visual C# Test Project.

    NoteNote:

    By default, the type of test project shown under Add to Test Project is the type that is currently set as the default in the Options dialog box, which is available onthe Tools menu. For more information, see How to: Configure Test Project Creation.

  3. In the Templates pane, select the type of test you want to add.

  4. Click OK.

    The New Test Project dialog box appears.

  5. Enter a name for the new test project, or accept the default name, and click Create.

  6. Depending on the type of test you chose, you can either hand-code or generate the newly added test.

The test project and the test it contains are added to your solution.

Create a test project as you generate unit tests

  1. Open a source-code file.

  2. Right-click a namespace, class, or method. For more information about how to create new unit tests, see How to: Create and Run a Unit Test.

  3. Click Create Unit Tests.

    The Create Unit Tests dialog box is displayed.

  4. (Optional) Change the selection of members for which you want to generate unit tests.

  5. Under Output project, choose one of the options for creating a new test project. For example, click Create a new Visual C# Test Project.

  6. Click Generate.

    The New Test Project dialog box is displayed.

  7. Enter a name for the new test project, or accept the default name, and click Create.

The test project is added to your solution together with the new unit test.

Create a test project by using the Add New Project dialog box

  1. In Solution Explorer, right-click the solution.

  2. Point to Add and click New Project.

    The Add New Project dialog box is displayed. The Project types pane contains a Test Projects node and nodes for specific programming languages.

  3. If you want your new test project to have a specific programming language, expand the node of that language; if not, expand Test Projects.

    NoteNote:

    Test projects are not available in every language.

  4. If you expanded a language node, click Test. If you expanded the Test Projects node, click Test Documents.

  5. Under Templates, click Test Project.

  6. (Optional) Change the name or location of the project you are about to add.

  7. Click OK.

The test project is added to your solution.

Community Additions

ADD
Show:
© 2014 Microsoft