我正在尝试向使用
创建的测试用例添加一个共享步骤。CreateWorkItemAsync()
创建测试步骤并将其添加到测试用例中没问题
ITestStep testStep1 = testBase.CreateTestStep();
但是我试图在测试案例中添加一个现有的共享步骤。我无法在Azure Devops SDK中找到一种方法。
答案 0 :(得分:0)
有一个ISharedStepReference接口,用于从测试用例中调用共享步骤集。
您应该能够将共享步骤添加到特定的测试用例中。供您参考的代码段:
ITestManagementService testService = tfsCollection.GetService<ITestManagementService>();
ITestManagementTeamProject teamProject = testService.GetTeamProject(teamProjectName);
//find test case by testcase id
ITestCase testcase1 = teamProject.TestCases.Find(192); //192 is the testcase id
//find share steps by sharedstep id
ISharedStep sharedStep1 = teamProject.SharedSteps.Find(140); //140 is the shared step id
//Add shareSteps to the specific test case
ISharedStepReference sharedStepReference = testcase1.CreateSharedStepReference();
sharedStepReference.SharedStepId = sharedStep1.Id;
testcase1.Actions.Add(sharedStepReference);
testcase1.Save();
答案 1 :(得分:0)
我最终要做的是使用创建测试用例
CreateWorkItemAsync()
然后使用
获取该工作项GetWorkItemAsync()
然后编辑字段
Microsoft.VSTS.TCM.Steps
as xml并将我自己的节点插入适当的位置,以将共享步骤添加到测试用例。您可以通过使用API GET请求获取测试用例并查看Microsoft.VSTS.TCM.Steps的格式来查看共享步骤的格式。