【问题标题】:Is there a way to bail the suite if a certain test fails?如果某个测试失败,有没有办法保释套件?
【发布时间】:2019-09-12 22:13:36
【问题描述】:

我有一项测试,如果失败,则表明应用程序存在较大问题。如果一个测试失败,那么运行其余的测试就没有任何意义。

如果单个测试失败,是否有办法保释套件,但如果该测试通过,则运行所有测试?

【问题讨论】:

    标签: testing e2e-testing functional-testing testcafe web-testing


    【解决方案1】:

    对于这种特定情况,我建议您使用programming interface。只有第一次启动成功后,才能第二次使用 run 方法。 请看以下代码:

    const createTestCafe = require('testcafe);
    let testcafe = null;
    
    createTestCafe('localhost', 1337, 1338)
        .then(tc => {
            testcafe = tc;
            const runner1 = testcafe.createRunner();
    
            return runner1
                .src(['test1'])
                .browsers('chrome')
                .run()
    
        })
        .then(() => {
            const runner2 = testcafe.createRunner();
    
            return runner2
                .browsers('chrome')
                .src(['test2'])
                .run();
        });
        .catch(err => {
            console.log(err);
            testcafe.close();
        })
    

    【讨论】:

    • 谢谢亚历克斯。我需要做一些额外的工作才能让这种特殊情况发生,这并不奇怪,它似乎不太可能得到开箱即用的支持。
    【解决方案2】:

    是的,这是可能的。 TestCafe 中有一个合适的选项 - stopOnFirstFail

    【讨论】:

    • 不,我想在特定失败时停止,而不是第一次失败。
    • 我建议您为此特定情况使用编程接口devexpress.github.io/testcafe/documentation/using-testcafe/…。只有第一次启动成功,才能第二次使用run方法。
    • 这似乎很公平——这应该是一个单独的答案; iirc 你在 testcafe 团队工作,所以如果你说这是必须完成的方式,我可以接受
    猜你喜欢
    • 2021-11-22
    • 2020-02-01
    • 1970-01-01
    • 2013-01-13
    • 2021-11-14
    • 2022-11-21
    • 2018-10-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多