我通过在C#中使用TFS API创建共享步骤结果。问题在于显示了步骤数,但结果摘要中没有显示标题(名称)。
请参见下面的代码。
注意:共享步骤中没有嵌套的步骤。
public static void AddStepResults(ITestCase tc, ITestCaseResult result)
{
string stName = "";
var iteration = result.CreateIteration(1);
TestActionCollection TestActions = tc.Actions;
for (int aIdx = 0; aIdx < TestActions.Count; aIdx++)
{
var action = TestActions[aIdx];
if (action is ISharedStepReference isr)
{
ISharedStep SharedAction = isr.FindSharedStep();
stName = SharedAction.Title.Trim();
ISharedStepResult stepResult = iteration.CreateSharedStepResult(action.Id, SharedAction.Id);
stepResult.Outcome = TestOutcome.Passed;
iteration.Actions.Add(stepResult);
}
else
{
ITestStep step = (ITestStep)action;
stName = step.Title;
ITestStepResult stepResult = iteration.CreateStepResult(step.Id);
stepResult.Outcome = TestOutcome.Passed;
iteration.Actions.Add(stepResult);
}
}
result.Iterations.Add(iteration);
}