Compartilhar via


How to run the same test in different Lab Environments?

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:

  1. The following post by Gautam explains the changes that will be required in the test code: https://blogs.msdn.com/b/gautamg/archive/2010/02/23/how-to-get-same-test-running-under-different-environments.aspx

  2. Extra requirement from VS Lab Management is that, the environment variable binding should be done using the following code:

    Environment.GetEnvironmentVariable("TestServer", EnvironmentVariableTarget.Machine);

 

Now, we need to configure our test machines to have the correct values of the environment variables, for achieving this we can do:

  1. 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.

or

  1. 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 https://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.

Comments

  • Anonymous
    September 26, 2011
    Hi, Interesting note about ability to run tests against both Physical and Virtual Environments in vNext. Any other upcoming features? One request: How about the ability to queue a test against a lab-managed environment in Visual Studio directly? Currently it doesn't work in 2010 due to the test controller being assigned to the lab environment only. Having this feature would allow consolidating lab environments so developers could use them more easily, and not needing to have two environments up just to allow both E2E workflows and a "test out of Visual Studio" experience