0
私はTFSテスト結果を実行した構成に対してのみ更新するように働いているようです。しかし、それは非常に非効率なようです。誰かが私が間違っていることを理解するのを助けることができますか? - 具体的には、特定のテストIDのtestSuitesを取得してから、それらのスイートのすべてのテストを繰り返して、すでに持っているテストIDと比較する必要があるように見えるわけではありません。設定によってTFSテスト結果を更新するにはどうすればよいですか?
例として、Windows 8/Chromeに対してテストを実行します。したがって、TestContextには、構成にマップされる適切な値が含まれています。私はそれが中に存在するすべてのテストスイートには、その構成のためのテスト結果を更新したいここでは、コードです:。
public void UpdateResult(TestContext context, bool passed)
{
int testCaseID = Convert.ToInt32(context.Test.Properties["id"]);
TfsTeamProjectCollection projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tfsUri);
ITestManagementService service = projectCollection.GetService<ITestManagementService>();
ITestManagementTeamProject teamProject = service.GetTeamProject(teamProjectName);
ITestCase testCase = teamProject.TestCases.Find(testCaseID);
ITestSuiteCollection testSuites = teamProject.TestSuites.ReferencingTestCase(testCaseID);
if (testCase != null)
{
// ---- Get Test Plan
int testPlanId = 20589;
ITestPlan testPlan = teamProject.TestPlans.Find(testPlanId);
// ---- Create Test Run
ITestRun testRun = teamProject.TestRuns.Create();
testRun = testPlan.CreateTestRun(true);
// ---- Get TestPoint
ITestPointCollection points = testPlan.QueryTestPoints("SELECT * FROM TestPoint WHERE TestCaseId =" + testCaseID);
foreach (ITestPoint tp in points)
{
//Get configuration, which contains configuration values
ITestConfiguration testConfiguration = teamProject.TestConfigurations.Query("Select * from TestConfiguration WHERE Name='" + tp.ConfigurationName + "'")[0];
IDictionary<string, string> testConfigValues = testConfiguration.Values;
if ((!testConfigValues.ContainsKey("Browser") ||
testConfigValues["Browser"].ToLower() == context.Test.Properties["Browser"].ToString().ToLower())
&& (!testConfigValues.ContainsKey("Operating System") ||
testConfigValues["Operating System"].ToLower() == context.Test.Properties["Operating System"].ToString().ToLower())
)
{
testRun.AddTestPoint(tp, testPlan.Owner);
}
}
testRun.State = TestRunState.Completed;
testRun.Save();
foreach (ITestSuiteBase testSuite in testSuites)
{
foreach (ITestSuiteEntry testCse in testSuite.TestCases)
{
ITestCaseResultCollection results = testRun.QueryResults();
if (testCse.TestCase.Id == testCaseID)
{
foreach (IdAndName config in testCse.Configurations)
{
IEnumerable<ITestCaseResult> testCaseResults = from tr in results
where
tr.TestConfigurationId == config.Id &&
tr.TestCaseId == testCase.Id
select tr;
foreach (ITestCaseResult result in testCaseResults)
{
result.Outcome = passed ? TestOutcome.Passed : TestOutcome.Failed;
result.State = TestResultState.Completed;
result.Save(true);
}
}
}
}
}
testRun.Save();
testRun.Refresh();
}
}
をピッカーは私にはあまり効果がありません。だから私は有用な部分がtestResults ByTestIdを取得していると仮定しています。それは参考になると分かりましたが、それは私の考えを解決しません。私が投稿した怪物をしない限り、私の問題はすべての構成の更新です。選択した構成をコードにのみ更新する方法を組み込むにはどうすればよいですか?また、AddTestPointを呼び出す必要はありませんか? –
あなたのコメントをお寄せください?私はあなたが与えたリンクを見てきましたが、アップデートにどのようにコンフィギュレーションを組み込むかについては話しません。 –