I will try to address today a common query by lot of users of Visual Studio Lab Management on how to correctly run tests in different Lab Environments.
This requirement can be achieved by making the test code read the Server names/other configuration through environment variables:
- The following post by Gautam explains the changes that will be required in the test code: http://blogs.msdn.com/b/gautamg/archive/2010/02/23/how-to-get-same-test-running-under-different-environments.aspx
- Extra requirement from VS Lab Management is that, the environment variable binding should be done using the following code:
Now, we need to configure our test machines to have the correct values of the environment variables, for achieving this we can do:
- Set this environment variables on the test execution machine before we trigger a test run manually. This approach can be used in cases where the values will not change frequently or from environment to environment.
- The values to the environment variables can be set as part of Deploy of Lab E2E Workflow. For doing this we add a deployment script to run the following command on test execution machine:
cmd /c setx /M TestServer $(InternalComputerName_testServerName)
Please refer http://msdn.microsoft.com/en-us/library/ee471614.aspx for information about Deploy and macros of Lab E2E workflow.
Note: The capability to run Lab E2E Workflow is only available for virtual environments in VS 2010. It is available for both Standard (Physical) and SCVMM environments in VS vNext.