visual-studio-2010 - VS 2010,编码的 UI 测试 : Re-run failed test cases

标签 visual-studio-2010 testing automation coded-ui-tests

我正在使用 VS2010 Premium,编码的 UI 测试。

你知道如何在运行后重新执行失败的测试用例吗? 如果重新执行后测试通过,则应在结果报告中通过。

最佳答案

不是最佳方式,但您可以将所有代码放入 try/catch block 并在抛出异常时重新运行测试:

[CodedUITest]
public class CodedUITest
{
    private static int _maxTestRuns = 5;

    [TestCleanup]
    public void Cleanup()
    {
        //If the test has reached the max number of executions then it is failed.
        if (_maxTestRuns == 0)
            Assert.Fail("Test executed {0} times and it was failed", _maxTestRuns);
    }

    [TestMethod]
    public void CodedUITestMethod()
    {
        try
        {
            this.UIMap.RecordedMethod1();
        }

        catch (Exception exception)
        {
            //Call Cleanup, rerun the test and report the error.
            if (_maxTestRuns > 0)
            {
                _maxTestRuns--;
                TestContext.WriteLine(exception.Message);
                TestContext.WriteLine("Running Again...");
                this.Cleaup();
                this.CodedUITestMethod();
            }
        }
    }
}

关于visual-studio-2010 - VS 2010,编码的 UI 测试 : Re-run failed test cases,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11801006/

相关文章:

c++ - 如何根据模板参数返回不同的类型

javascript - 如何在没有网络浏览器交互的情况下在 nightwatch.js 中等待任意时间

testing - Grails 集成测试过滤器

linux - 当条件处于ansible状态时

c++ - vc++ 2010 文档生成器

c++ - 为 C++ 设置 Direct X 时出现问题

javascript - 引用 javascript 嵌入式资源但智能感知不显示任何内容

android - Robotium 如何使用转换等后台服务进行测试?

css - 如何将 rgba 值转换为人类可读的文本

c++ - 程序 (nload) 在 shell 中执行时作为守护进程运行,但不在启动/自动化脚本中执行