可以通过以下代码来撤销将“Automation status”更新为“Automated”:
示例代码如下:
using Microsoft.TeamFoundation.TestManagement.Client;
// Connect to the TFS server
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri("http://tfsserver:8080/tfs"));
tfs.Authenticate();
// Get the test plan
ITestManagementService tms = tfs.GetService();
ITestManagementTeamProject project = tms.GetTeamProject("project name");
ITestPlan plan = project.TestPlans.Find(1);
// Find the test cases to undo the update for
ITestCaseCollection testCases = plan.RootSuite.AllTestCases;
foreach (ITestCase testCase in testCases)
{
if (testCase.Title == "Test Case Title")
{
// Undo the update
testCase.Actions.RemoveAt(0);
testCase.Actions.Add(new Microsoft.TeamFoundation.TestManagement.Client.DesignStep()
{
ExpectedResult = "Expected result",
Description = "Description",
StepNumber = 1
});
// Save the changes
project.WitBatchSave(testCase.WorkItem);
break;
}
}
其中,“Test Case Title”应该替换为要撤销更改的测试用例的标题。