Varun Bajpai
Varun Bajpai

Reputation: 555

Getting configuration value set in MTM from TFS at the run time

I have some selenium test cases which i execute using MTM. i have to execute tests on different operating system and browsers, to set these i use a configuration file. what i want is to get the value of Browser and Operating System from the configuration which we set in MTM i.e. if i execute a test using configuration having Operating system and browser values set to Windows 7 and Chrome respectively, it should automatically set the value of OS to Windows 7 and Browser to Chrome for that particular test run. Next if i select some other configuration having different set of values it should run using those values of OS and Browser.

How can i get these values in my code?

Upvotes: 0

Views: 1172

Answers (1)

NDDeveloper
NDDeveloper

Reputation: 11

using (TfsTeamProjectCollection collection = new TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName("<YourTFSServerURL>")))
{
    ITestManagementService tcmService = collection.GetService<ITestManagementService>();
    ITestManagementTeamProject project = tcmService.GetTeamProject("<YourTFSProject>");

    //Get configuration, which contains configuration values
    ITestConfiguration testConfiguration = project.TestConfigurations.Query("Select * from TestConfiguration WHERE Name='" + yourConfigurationName + "'")[0];
    IDictionary<string, string> testConfigValues = testConfiguration.Values;

    string browser = testConfigValues["Browser"];
    string operatingSystem = testConfigValues["Operating System"];
}

Upvotes: 1

Related Questions