Server name parametrization


Server name parameterization in Visual Studio will allow only for parametrising server hostname. This might prove a bit limited when more than one version of the application is hosted under the same hostname.

In the following example two different releases of the same application are accessible via one hostname but different context path:

http://webserver_one/release_one
http://webserver_one/release_two

The Visual Studio can only parameterise the webserver_one part of the URL which is not going to solve the problem.
In order to parameterize the domain name and context path one can take advantage of the WebTest file format and open the test in Visual Studio build-in XML editor.

This could be done by right clicking on the WebTest and selecting Open With option.
Using XML editor the required string can be substituted with a WebTest context parameter using search and replace feature.

In the above example the search/replace parameters would be:
  • Search: http://webserver_one/release_one
  • Replace with: {{ServerAddress}}

Once the edited test has been modified and saved it will have {{ServerAddress}} in a place of the release specific part of the URL.

Before the test could be run the ServerAddress context parameter needs to be defined in the test. Its value should be the same as one of the replaced server addresses e.g. http://webserver_one/release_one


Comments