如何访问测试用例共享步骤的结果
How can I access the outcome of shared steps of a test case
我需要检索每个共享步骤的状态(通过\失败\否 运行)。我能够访问共享的步骤标题和预期结果,并且我需要检索结果和评论。我知道可以从该测试执行的 ITestIterationResult(s) 中检索这些详细信息,但有人可以指导我使用代码。请帮我解决这个问题,下面是我到目前为止所拥有的。
public ISharedStep tstSharedStep { 得到;私有集; }
public ISharedStepReference tstSharedStepRef { 得到;私有集; }
foreach (ITestAction tstAction in tstCase.Actions)
{
tstSharedStep = null;
tstSharedStepRef = tstAction as ISharedStepReference;
if (tstSharedStepRef != null)
{
tstSharedStep = tstSharedStepRef.FindSharedStep();
foreach (ITestAction tstSharedAction in tstSharedStep.Actions)
{
ITestStep tstSharedTestStep = tstSharedAction as ITestStep;
resultData.Step = Regex.Replace(tstSharedTestStep.Title, @"<[^>]+>| ", "").Trim();
resultData.ExpectedResult = Regex.Replace(tstSharedTestStep.ExpectedResult, @"<[^>]+>| ", "").Trim();
}
}
else {
// regular step action
}
}
我找到了这个问题的解决方案,并认为我会分享它..
ISharedStep shared_step = null;
ISharedStepReference shared_ref = act as ISharedStepReference;
if (shared_ref != null)
{
shared_step = shared_ref.FindSharedStep();
ITestActionResult actionResult = iteration.FindActionResult(act);
if (actionResult is ISharedStepResult)
{
ISharedStepResult sharedStepResult = actionResult as ISharedStepResult;
foreach (var shareTestActionResult in sharedStepResult.Actions)
{
sharedData = new TestSharedResult();
sharedData.SharedStepOutcome = shareTestActionResult.Outcome.ToString();
sharedData.SharedStepComment = shareTestActionResult.ErrorMessage.ToString();
sharedResultDataList.Add(sharedData);
}
}
}
我需要检索每个共享步骤的状态(通过\失败\否 运行)。我能够访问共享的步骤标题和预期结果,并且我需要检索结果和评论。我知道可以从该测试执行的 ITestIterationResult(s) 中检索这些详细信息,但有人可以指导我使用代码。请帮我解决这个问题,下面是我到目前为止所拥有的。
public ISharedStep tstSharedStep { 得到;私有集; }
public ISharedStepReference tstSharedStepRef { 得到;私有集; }
foreach (ITestAction tstAction in tstCase.Actions)
{
tstSharedStep = null;
tstSharedStepRef = tstAction as ISharedStepReference;
if (tstSharedStepRef != null)
{
tstSharedStep = tstSharedStepRef.FindSharedStep();
foreach (ITestAction tstSharedAction in tstSharedStep.Actions)
{
ITestStep tstSharedTestStep = tstSharedAction as ITestStep;
resultData.Step = Regex.Replace(tstSharedTestStep.Title, @"<[^>]+>| ", "").Trim();
resultData.ExpectedResult = Regex.Replace(tstSharedTestStep.ExpectedResult, @"<[^>]+>| ", "").Trim();
}
}
else {
// regular step action
}
}
我找到了这个问题的解决方案,并认为我会分享它..
ISharedStep shared_step = null;
ISharedStepReference shared_ref = act as ISharedStepReference;
if (shared_ref != null)
{
shared_step = shared_ref.FindSharedStep();
ITestActionResult actionResult = iteration.FindActionResult(act);
if (actionResult is ISharedStepResult)
{
ISharedStepResult sharedStepResult = actionResult as ISharedStepResult;
foreach (var shareTestActionResult in sharedStepResult.Actions)
{
sharedData = new TestSharedResult();
sharedData.SharedStepOutcome = shareTestActionResult.Outcome.ToString();
sharedData.SharedStepComment = shareTestActionResult.ErrorMessage.ToString();
sharedResultDataList.Add(sharedData);
}
}
}