Update The Web Server Parameter In MSBuild For Team System Web Tests
As you are probably aware, Visual Studio Team System Test Edition allows you to create web tests. Basically these are tests that a user records in the browser while navigating through a web application. These can then be played back along with a suite of tests to verify a web application's behavior.
Once you have created a web test it is possible to parameterize the URL that your web test is running against. To do this open your web test and right click the root of the test, select parameterize web servers... Set the context parameter name and web server you want to default to. Upon creation, it is now possible to change the path to the web site and execute this test from the command line by setting an environment variable. This is done on the command line with the command set Test.WebServer1=http://MyProductionServer. Change WebServer1 to match the name of the context variable used in the web test. Finally, use MSText.exe to run the test.
Once you have created the context parameter you can now create a build that can set that context parameter before the test is executed using the method explained above. To do this you will first need to download SDC Tasks, this is a collection of MSBuild tasks. We will be using the Set Environment Variable task for this sample.
The first thing you will need to configure is the InitialTargets parameter as shown below so that the set environment variable target gets called first.
<Project DefaultTargets="DesktopBuild" InitialTargets="SetEnvironmentVar" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
The next thing you will have to do is import the SDC tasks. Make sure these binary's are on the build server.
<Import Project="C:\BuildTools\Microsoft.Sdc.Common.tasks"/>
Finally, create a parameter for the server name and then call the SetEnvironmentVariable in the SetEnvironmentVar target.
<PropertyGroup>
<TEST_SERVER_NAME>QAServer</TEST_SERVER_NAME>
</PropertyGroup>
<Target Name="SetEnvironmentVar">
<SetEnvironmentVariable Variable="Test.WebServer1" Value=http://$(TEST_SERVER_NAME) Target="Process"/>
</Target>
Hopefully this allows you to dynamically change the web site path when executing web tests in MSBuild.
Similar Posts
- Configure App.config Application Settings During MSI Install
- Team Foundation Server Build Notification Screen
- Using VSDBCMD and MSBUILD to Build and Deploy DBPro Projects
