簡體   English   中英

在運行時從TFS獲取MTM中設置的配置值

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

我有一些使用MTM執行的硒測試用例。 我必須在不同的操作系統和瀏覽器上執行測試,然后使用配置文件進行設置。 我想要的是從我們在MTM中設置的配置中獲取“瀏覽器”和“操作系統”的值,即,如果我使用將“操作系統”和“瀏覽器”值分別設置為Windows 7和Chrome的配置來執行測試,則它應該自動設置針對該特定測試運行的操作系統為Windows 7,瀏覽器為Chrome。 接下來,如果我選擇其他一些具有不同值集的配置,則應使用OS和Browser的那些值來運行。

如何在代碼中獲取這些值?

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"];
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM