0

我需要检索每个共享步骤的状态(通过\失败\未运行)。我能够访问共享步骤标题和预期结果,我需要检索结果和评论。我知道可以从 ITestIterationResult(s) 中检索这些详细信息以执行该测试,但有人可以指导我使用代码。请帮助我解决这个问题,以下是我到目前为止所拥有的。

公共 ISharedStep tstSharedStep { 获取;私人套装;}

公共 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, @"<[^>]+>|&nbsp;", "").Trim();
                        resultData.ExpectedResult = Regex.Replace(tstSharedTestStep.ExpectedResult, @"<[^>]+>|&nbsp;", "").Trim();

                    }
                }
                else {
                 // regular step action
                }

}

4

1 回答 1

1

我能够找到解决方案,并认为我会分享它..

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);
                                                }
                                            }
                                        }
于 2015-06-29T11:38:06.163 回答