2016-11-28 79 views

回答

0

你会想要使用Actions属性。这将返回TestActionCollection您可以用来更新步骤。您可以对集合中的每个操作使用ITestStep界面来更新每个步骤的标题,描述和ExpectedResult。不要忘记在工作项目上致电Save()

0

测试用例与Bug或Task等正常工作项目不同。您需要使用Microsoft.TeamFoundation.TestManagement.Client中的“ITestManagementService”来更新测试用例。查看以下代码以供参考:

using System; 
using Microsoft.TeamFoundation.Client; 
using Microsoft.TeamFoundation.TestManagement.Client; 

namespace TFSDownloadFile 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      string url = "http://tfscollectionurl/"; 
      TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(url)); 
      ITestManagementService itms = ttpc.GetService<ITestManagementService>(); 
      ITestManagementTeamProject itmtp = itms.GetTeamProject("YourProject"); 
      //Get test case with test case id 
      ITestCase itc = itmtp.TestCases.Find(1); 
      //Get the first step in test case 
      ITestStep teststep = itc.Actions[0] as ITestStep; 
      //Update the test step 
      teststep.Title = "New Title"; 
      teststep.ExpectedResult = "New ExpectedResult"; 
      //Save the updated test case 
      itc.Save(); 
     } 
    } 
}