How to: Parameterize the URL for a Web Performance Tests Web Server
You can parameterize the URL for your Web server. The purpose of parameterization is to make it easy to change the Web server that your tests target. A test, either recorded or coded, can run against various servers. When you use parameterization, you can easily change servers by re-mapping the Web server context parameter to another server. You do not have to re-record or re-write the test.
This is useful when, for example, you want to run tests on a Web server that has one name in your non-production environment and another name in your production environment. In this case, both the Web servers are active Web servers.
You can also have Web Performance tests target the ASP.NET Development Web Server on your local computer. You can create Web services on your local computer that use the ASP.NET Development Server to host your Web application. For more information about ASP.NET Development Server, see Web Servers in Visual Web Developer.
Additionally, if your test will run on a designated test Web server for build verification, the target Web site can be identified outside the actual Web Performance test. Identifying the Web server outside the test lets you avoid editing any part of the test that is under source code control.
A load test context parameter overrides a Web performance test context parameter of the same name.
Visual Studio Ultimate
To create a context parameter for a Web server
Open a Web Performance test.
Choose the Parameterize Web Servers button.
In the Parameterize Web Servers dialog box, select the Web server that you want to parameterize and then choose Change.
The Change Web Server dialog box appears.
In the Change Web Server dialog box, type a name for the Context parameter name.
Select either Use Web server or ASP.NET Development Server.
If you choose ASP.NET Development Server, you must indicate the path to the Web site on your local computer and the Web application root.
You can parameterize the path to the Web site by using an environment variable, such as Test.WebServer1. For example, from a command line, type set Test.WebServer1=http://MyProductionServer. Then, if you run the Web Performance test from the command line by using MSTest.exe, the environment variable will be in effect for that test run. For more information about how to run tests from a command line, see How to: Run Automated Tests from the Command Line Using MSTest.
If you have more than one Web server to map, you can select it, and then repeat the procedure. When you have finished mapping the Web servers to context parameter names, choose OK.
The context parameters are visible in the Web Performance test. You can see the mappings between the context parameter name and the Web server.
The ASP.NET Development Servers are automatically started and stopped at the end of the test run.