我試圖使用TFS API來更新單獨運行的自動化測試結果。我嘗試了其他問題的建議(特別是How to create a test run and result using the Team Foundation Server API?)以及其他地方的搜索。不管我怎麼努力我有同樣的問題:每次我試圖將一個測試點添加到試運行的時候,我收到錯誤 -TFS 2012 API:無法將測試點添加到測試運行
Microsoft.TeamFoundation.TestManagement.Client.TestManagementInvalidOperationException: This test run cannot be created with the test points.
測試點由TFS使用WIQL檢索,和我檢查每個測試點在我嘗試添加測試計劃,測試套件和測試配置之前要確保它是正確的。
我無法保存沒有測試點的測試運行。
private void ConfigureTestRun()
{
this.Run.DateStarted = DateTime.Now;
this.Run.DateCompleted = DateTime.Now;
// find the points that correspond to test cases in the run suite
foreach (ITestPoint point in this.Points)
{
if (point.TestCaseExists && point.Plan.Id == this.Plan.Id && point.ConfigurationId == this.Config.Id)
{
this.Run.AddTestPoint(point, this.CurrentUser); // fails with InvalidOperationException
}
}
this.Run.Save();
}
我能:
示例代碼
public void UpdateTests(TestSuiteRun suiteRun)
{
this.Config = FindConfig(suiteRun.Description);
this.Suite = FindSuite(suiteRun.Name);
this.Plan = Suite.Plan;
this.Points = FindPoints(this.Suite.Id, this.Config.Id);
ITestCaseCollection testCases = Suite.AllTestCases;
this.Run = TeamProject.TestRuns.Create();
ConfigureTestRun(); // failing here
this.Result = CreateRunResults();
this.Iteration = CreateSingleIteration(suiteRun.Description);
{
UpdateResultsForScenario(scen);
}
}
而且方法來配置試運行(我已經經歷了這麼多努力,現在我的代碼已經超出了凌亂)連接到TFS並檢索我需要的所有數據,但將測試點添加到新的測試運行正在讓我發瘋。
我做錯了什麼?
什麼是「保存」的回報,如果它是一個布爾值,什麼是結果? – DaveShaw
@DaveShaw我沒有去「保存」 - 例程在Run.AddTestPoint()上失敗。 –