Is it possible to get the name of the currently running Test List RRS feed

  • Question

  • Our test servers are segregated by language, and I store the server name in App.config.  I've built my coded ui tests to be language agnostic and to read the server url and navigate to the correct site. I'd like to take it one step further and create test lists because each server supports a subset of the full feature set. I'd like to be able to get the Test List name at the start and then pull the server name from App.config using the test list name as the key.  I don't see any properties in TextContext object that reveals the running Test List, however.  Is there another approach I could take?

    Thursday, June 30, 2011 9:05 PM

All replies

  • Hi,

    I am not able to think of a direct programmatic approach for this right now. Here is one possible workaround though:

    Your test solution will have a ProjectName.vsmdi which has the details of the test lists, if you have created any. This file is an XML file that you can read using relevant XML classes (XMLReader). The node concerned will be <TestList>. Just read the "name" attributes value for this node and you have the testlist name.



    Friday, July 1, 2011 10:28 PM
  • Thanks for the suggestion.  I could get the names of all the test lists from the vsmdi file; but I still would like to find out which test list is currently checked and running.  I wonder if there is another metadata file that contains this information during test execution?
    Thursday, July 7, 2011 6:39 PM
  • Hi,


    If the Test Class name or the Test Method name can help you deciding the server, then you can use either of the two:




    This will give the name of the TestMethod currently being executed or the name of the Current Test Class being processed.




    Friday, July 8, 2011 4:07 AM
  • The solution I came up with is another approach to the problem but others might be interested in this technique.  To run each test list against a different host I run the tests from the command line using an environment variable to store the url of the target server.

    Step 1.        Create a .bat file with the test commands using the below pattern.


    if "%1"=="Germany" (

      SET Test.TargetServer=testde2.mydomain.com

      Mstest.exe /testmetadata:"BVT.vsmdi" /testlist:"BVT - Germany"


    if "%1"=="France" (

      SET Test.TargetServer=testfr2.domain.com

      Mstest.exe /testmetadata:"BVT.vsmdi" /testlist:"BVT - France"



    Step 2.       In the C# code where I get my host url from app.config, allow it to be overriden by an environment variable:

             public static string GetTargetServer()


                 string targetServer = Environment.GetEnvironmentVariable("Test.TargetServer");

                 if (string.IsNullOrEmpty(targetServer))


                     targetServer = ConfigurationManager.AppSettings["TargetServer"];


                 return targetServer;




    3. Run the tests from the VS command line supplying one parameter:

    RunGlobalBVT.bat Germany

    RunGlobalBVT.bat France


    Wednesday, July 20, 2011 5:44 PM