How to: Add context parameters to a load test run setting
Applies to: Visual Studio Visual Studio for Mac Visual Studio Code
After you create your load test by using the New Load Test Wizard, you can use the Load Test Editor to change the scenarios properties to meet your testing needs and goals.
Web performance and load test functionality is deprecated. Visual Studio 2019 is the last version where web performance and load testing will be fully available. For more information, see the Cloud-based load testing service end of life blog post. To reduce the impact on users, some minimum support is still available in Visual Studio 2022. (You can run existing web/load tests, but the templates to create new tests were removed.) Users should also note web performance and load test functionality only supports Internet Explorer, which is not available on Windows 11 and some versions of Windows 10. The web recorder feature is also deprecated because it requires Internet Explorer. Read more on Internet Explorer Lifecycle policy. We recommend that you use Azure Load Testing as an alternative.
For a full list of the run settings properties and their descriptions, see Load test run settings properties.
You can create context parameters to use in a load test run setting by using the Load Test Editor. Context parameters let you parameterize a string.
Suppose your load test contains a web performance test that already uses a parameterized web server URL by using a context parameter. You can add a context parameter to a load test run setting that uses the same name value as the one that is used in the web performance test. This will map the web performance test to a different server when you run the load test. For example, if your load test includes a web performance test that uses a context parameter that is named WebServer1 for the name of the web server in the URL. If you then specify a context parameter in your load test run setting that is also named WebServer1, the load test will use the context parameter that you assigned in the load test run setting. To clarify, if the web performance test in the load test uses the same context parameter name as a context parameter in the load test, the context parameter in the load test will override the context parameter that is used in the web performance test.
Be careful not to unintentionally override the context parameter of a web performance test when you use context parameters in a run setting. Avoid using the same context parameter names unless you do this intentionally.
If you assign the value of the Webserver1 context parameter to
http://CorporateStagingWebServer, you can then use
WebServer1 throughout the load test and thereby easily change the value to a different web server at any time.
Additionally, by assigning different values to a context parameter by using the same name in different load test run settings, you can run the load test by using different environments:
Corporate Staging Web Server run setting: The context parameter that is named
Corporate Production Web Server run setting: The Context parameter that is named
Changing the Run Setting from the Command Line
If you want to use different run settings from the command line to take advantage of the context parameter strategy, use the following commands:
Set Test.UseRunSetting= CorporateStagingWebServer
To add a context parameter to a run setting
Open a load test.
Expand the Run Settings folder in the load test tree in the Load Test Editor.
Right-click the specific run setting to which you want to add a context parameter and then choose Add Context Parameter.
A new context parameter is added to the Context Parameters folder in the Run Settings folder in the load test tree.
If the run setting already contains a Context Parameters folder, you can right-click it and then choose Add Context Parameter.
In the Properties window, change the value for Name as appropriate (for example, WebServer1). In the Properties window, change Value to the parameter that you want to use (for example,
(Optional) Repeat steps 3 through 5 and use a different string for the Value property (for example,
Choose which run settings that you want to be active. Open the shortcut menu on the run settings and choose Set As Active.
Submit and view feedback for