【问题标题】:How can I access the outcome of shared steps of a test case如何访问测试用例共享步骤的结果
【发布时间】:2015-06-29 19:38:06
【问题描述】:

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

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

公共 ISharedStepReference tstSharedStepRef { get;私人套装; }

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
                }

}

【问题讨论】:

    标签: tfs mtm


    【解决方案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);
                                                    }
                                                }
                                            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-10
      • 2017-12-01
      相关资源
      最近更新 更多