How to: Configure Tests with Build Types

This topic explains how to modify build types and projects to use the testing capabilities of Team Foundation Build. The following test types are covered in this topic:

  • ASP.NET unit tests

  • Web service unit tests

  • Web tests

  • Load tests

  • Ordered test

  • Generic tests

    Note

    In order to run tests during build, Team Edition for Testers must be installed on the build computer.

Required Permissions

To perform these procedures, you must have the Team Foundation Administrators security permission set to Allow. For more information, see Team Foundation Server Permissions.

Requirements for Building Web Projects

To build a Web project using Team Foundation Build it must be configured to be updatable.

To configure the Web project to be updatable

  1. In Solution Explorer, select the Web project.

  2. On the View menu, click Property Pages.

  3. In the left pane, click MSBuild Options.

  4. Select Allow this precompiled site to be updatable.

Note

By default, this option is already selected.

ASP.NET Unit Tests

ASP.NET projects can be tested in the following ways:

To test ASP.NET projects in IIS

  1. Create an ASP.NET project. For more information, see How to: Create Local IIS Web Sites.

  2. Open the .sln file in a text editor, such as Notepad.

    Note

    By default, the .sln file of an ASP.NET project is located in My Documents\Visual Studio 2005\projects\WebSiteName.

  3. Set the Debug.AspNetCompiler.PhysicalPath and Release.AspNetCompiler.PhysicalPath values equal to "..\SolutionName\WebProjectName".

  4. Create a unit test for the project. For more information, see Overview of ASP.NET Unit Tests.

  5. Check in the Web project and test project.

  6. Create a new build type and select the test to run during the build. For more information, see How to: Create a New Build Type.

    Note

    In the Select configurations to build step of the New Team Build Type Creation Wizard, you must type Mixed Platform in the Platform box for the Web project and test to successfully build.

  7. Manually publish the Web site on the build machine.

  8. Run the build type.

To test ASP.NET projects on an ASP.NET Development Server

  1. Create an ASP.NET project.

  2. Open the .sln file in a text editor, such as Notepad.

    Note

    By default, the .sln file of an ASP.NET project is located in My Documents\Visual Studio 2005\projects\WebSiteName.

  3. Set the Debug.AspNetCompiler.PhysicalPath and Release.AspNetCompiler.PhysicalPath values equal to "..\SolutionName\WebProjectName".

  4. Create a unit test for the project. For more information, see Overview of ASP.NET Unit Tests.

  5. Change the path of the AspNetDevelopmentServerHost attribute in the test method to %PathToWebRoot%. For more information, see Testing Web Sites and Web Services in Team System.

  6. Check in the Web project and test project.

  7. Create a new build type and select the test to run during the build. For more information, see How to: Create a New Build Type.

    Note

    In the Select configurations to build step of the New Team Build Type Creation Wizard, you must type Mixed Platform in the Platform box for the Web project and test to successfully build.

  8. Run the build type.

Web Service Unit Tests

Web services can be tested in the following ways:

To test Web services in IIS

  1. Create a Web service project. For more information, see Walkthrough: Creating an XML Web Service Using Visual Basic or Visual C#.

  2. Open the .sln file in a text editor, such as Notepad.

    Note

    By default, the .sln file of an ASP.NET project is located in My Documents\Visual Studio 2005\projects\WebSiteName.

  3. Set the Debug.AspNetCompiler.PhysicalPath and Release.AspNetCompiler.PhysicalPath values equal to "..\SolutionName\WebProjectName".

  4. Create a unit test for the project. For more information, see Overview of ASP.NET Unit Tests.

  5. Add the following code to the test method, where WebServiceObject is the Web service object, and Location is the location of the Web service.

    WebServiceObject.URL = "Location";
    
  6. Check in the Web project and test project.

  7. Create a new build type and select the test to run during the build. For more information, see How to: Create a New Build Type.

    Note

    In the Select configurations to build step of the New Team Build Type Creation Wizard, you must type Mixed Platform in the Platform box for the Web project and test to successfully build.

  8. Run the build type.

To test Web services on an ASP.NET Development Server

  1. Create a Web service project. For more information, see Walkthrough: Creating an XML Web Service Using Visual Basic or Visual C#.

  2. Open the .sln file in a text editor, such as Notepad.

    Note

    By default, the .sln file of an ASP.NET project is located in My Documents\Visual Studio 2005\projects\WebSiteName.

  3. Set the Debug.AspNetCompiler.PhysicalPath and Release.AspNetCompiler.PhysicalPath values equal to "..\SolutionName\WebProjectName".

  4. Create a unit test for the project. For more information, see How to: Generate a Unit Test.

  5. Include the Microsoft.VisualStudio.QualityTools.UnitTesting.Web namespace in the test class.

  6. Add the AspNetDevelopmentServerAttribute attribute to the unit test. For more information, see Testing Web Services.

  7. Add a call to the TryUrlRedirection method. For more information, see the "Using the TryUrlRedirection Method" section in Testing Web Services.

  8. Check in the Web service and test project.

  9. Create a new build type and select the test to run during the build. For more information, see How to: Create a New Build Type.

    Note

    In the Select configurations to build step of the New Team Build Type Creation Wizard, you must type Mixed Platform in the Platform box for the Web project and test to successfully build.

  10. Manually publish the Web site on the build machine.

  11. Run the build type.

Web Tests

To run Web tests with Team Foundation Build, the Team Foundation Build Service must be running under the Administrator account on the build machine. For more information about how to install Team Foundation Build, see How to: Set Up a Build Computer.

Web tests can be run in the following ways:

For more information about Web tests, see Working with Web Tests.

To run Web tests on IIS

  1. Create a Web project.

  2. Open the .sln file in a text editor, such as Notepad.

    Note

    By default, the .sln file of an ASP.NET project is located in My Documents\Visual Studio 2005\projects\WebSiteName.

  3. Create a new Web test.

  4. Check in the Web project and test project.

  5. Create a new build type and select the test to run during the build. For more information, see How to: Create a New Build Type.

    Note

    In the Select configurations to build step of the New Team Build Type Creation Wizard, you must type Mixed Platform in the Platform box for the Web project and test to successfully build.

  6. Manually publish the Web site on the build machine.

  7. Run the build type.

To run Web tests on an ASP.NET Development Server

  1. Create a Web project.

  2. Open the .sln file in a text editor, such as Notepad.

    Note

    By default, the .sln file of an ASP.NET project is located in My Documents\Visual Studio 2005\projects\WebSiteName.

  3. Set the Debug.AspNetCompiler.PhysicalPath and Release.AspNetCompiler.PhysicalPath values equal to "..\SolutionName\WebProjectName".

  4. Create a Web test. For more information, see Creating a Web Test.

  5. In Solution Explorer, right-click the .webtest file, and then click Open.

  6. Click the Parameterize Web Server button.

  7. Select the Web Server to parameterize, and then click Change.

  8. Select Use ASP.NET Development Server.

  9. In the Path to Web site box, type **%PathToWebRoot%\**WebSiteProjectName.

  10. In the Web application root box, enter the Web application root.

  11. Click OK, and then click OK again.

  12. Check in the Web service and test project.

  13. Create a new build type and select the test to run during the build. For more information, see How to: Create a New Build Type.

    Note

    In the Select configurations to build step of the New Team Build Type Creation Wizard, you must type Mixed Platform in the Platform box for the Web project and test to successfully build.

  14. Run the build type.

Load Testing

For more information about load testing, see Working with Load Tests.

To configure a load test for use with Team Foundation Build

  1. Create a load test. For more information, see Creating Load Tests.

  2. Make sure that SQL Server Express is installed on the build machine and that the Team Build Service has permission to write to SQL Server Express.

  3. Create a new build type and select the test to run during the build. For more information, see How to: Create a New Build Type.

  4. Run the build type.

    Note

    To view test results for the load test, you might have to change some configuration settings if the load test repository was on a SQL Server Express setup. If this is the case, enable Remote Connections for SQL Server Express on the build machine.

Ordered Testing

For more information about ordered tests, see Working with Ordered Tests.

To configure a ordered test for use with Team Foundation Build

  1. Create an ordered test. For more information, see How to: Create an Ordered Test.

  2. Create a new build type and select the test to run during the build. For more information, see How to: Create a New Build Type.

  3. Run the build type.

Generic Testing

For more information about generic tests, see Working with Generic Tests.

To configure a generic test for use with Team Foundation Build

  1. Create a generic test. For more information, see How to: Create a Generic Test.

  2. Create a new build type and select the test to run during the build. For more information, see How to: Create a New Build Type.

  3. Run the build type.

See Also

Concepts

Testing Web Sites and Web Services in a Team Environment

Other Resources

Working with Build Types in Team Foundation Build
Test Types