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
In Solution Explorer, select the Web project.
On the View menu, click Property Pages.
In the left pane, click MSBuild Options.
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:
On either a local or remote Web server, such as IIS.
On an ASP.NET Development Server. For more information, see Web Servers in Visual Web Developer.
To test ASP.NET projects in IIS
Create an ASP.NET project. For more information, see How to: Create Local IIS Web Sites.
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.
Set the
Debug.AspNetCompiler.PhysicalPath
andRelease.AspNetCompiler.PhysicalPath
values equal to "..\SolutionName\WebProjectName".Create a unit test for the project. For more information, see Overview of ASP.NET Unit Tests.
Check in the Web project and test project.
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.
Manually publish the Web site on the build machine.
Run the build type.
To test ASP.NET projects on an ASP.NET Development Server
Create an ASP.NET project.
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.
Set the
Debug.AspNetCompiler.PhysicalPath
andRelease.AspNetCompiler.PhysicalPath
values equal to "..\SolutionName\WebProjectName".Create a unit test for the project. For more information, see Overview of ASP.NET Unit Tests.
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.Check in the Web project and test project.
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.
Run the build type.
Web Service Unit Tests
Web services can be tested in the following ways:
On either a local or remote Web server, such as IIS.
On an ASP.NET Development Server. For more information, see Web Servers in Visual Web Developer.
To test Web services in IIS
Create a Web service project. For more information, see Walkthrough: Creating an XML Web Service Using Visual Basic or Visual C#.
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.
Set the
Debug.AspNetCompiler.PhysicalPath
andRelease.AspNetCompiler.PhysicalPath
values equal to "..\SolutionName\WebProjectName".Create a unit test for the project. For more information, see Overview of ASP.NET Unit Tests.
Add the following code to the test method, where
WebServiceObject
is the Web service object, andLocation
is the location of the Web service.WebServiceObject.URL = "Location";
Check in the Web project and test project.
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.
Run the build type.
To test Web services on an ASP.NET Development Server
Create a Web service project. For more information, see Walkthrough: Creating an XML Web Service Using Visual Basic or Visual C#.
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.
Set the
Debug.AspNetCompiler.PhysicalPath
andRelease.AspNetCompiler.PhysicalPath
values equal to "..\SolutionName\WebProjectName".Create a unit test for the project. For more information, see How to: Generate a Unit Test.
Include the Microsoft.VisualStudio.QualityTools.UnitTesting.Web namespace in the test class.
Add the AspNetDevelopmentServerAttribute attribute to the unit test. For more information, see Testing Web Services.
Add a call to the TryUrlRedirection method. For more information, see the "Using the TryUrlRedirection Method" section in Testing Web Services.
Check in the Web service and test project.
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.
Manually publish the Web site on the build machine.
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:
On either a local or remote Web server, such as IIS.
On an ASP.NET Development Server. For more information, see Web Servers in Visual Web Developer.
For more information about Web tests, see Working with Web Tests.
To run Web tests on IIS
Create a Web project.
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.
Create a new Web test.
Check in the Web project and test project.
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.
Manually publish the Web site on the build machine.
Run the build type.
To run Web tests on an ASP.NET Development Server
Create a Web project.
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.
Set the
Debug.AspNetCompiler.PhysicalPath
andRelease.AspNetCompiler.PhysicalPath
values equal to "..\SolutionName\WebProjectName".Create a Web test. For more information, see Creating a Web Test.
In Solution Explorer, right-click the .webtest file, and then click Open.
Click the Parameterize Web Server button.
Select the Web Server to parameterize, and then click Change.
Select Use ASP.NET Development Server.
In the Path to Web site box, type **%PathToWebRoot%\**WebSiteProjectName.
In the Web application root box, enter the Web application root.
Click OK, and then click OK again.
Check in the Web service and test project.
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.
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
Create a load test. For more information, see Creating Load Tests.
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.
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.
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
Create an ordered test. For more information, see How to: Create an Ordered Test.
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.
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
Create a generic test. For more information, see How to: Create a Generic Test.
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.
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