实习生功能测试:跳过套件/测试

Bru*_*ano 3 javascript intern

我正在使用 Intern/Leadfoot 编写一些功能测试。这些测试是端到端测试(也称为故事),它们之间存在某种数据依赖性。我的意思是,如果之前的测试 (test1) 没有成功完成,则测试 (即 test2) 将失败。因此,为了避免运行肯定失败的测试,我想跳过它们(或其中的一部分)。因此,我想知道是否有办法实现这一目标。

考虑到所有 test.js 文件都类似于以下文件:

define([
    "require",
    "intern", 
    "intern!object",
    "../../support/executor/executor"],
    function(require, intern, registerSuite, Executor) {

    var executor;
    var steps = [

        // set of actions, 
        // like login, click this button,
        // then assert that ....
    ];

    registerSuite(function() {
        return {
            setup: function() {
                executor = new Executor(this.remote, steps.slice(0));
            },

            "Test 1": function() {
                return executor.run();
            },
        };
    });
});
Run Code Online (Sandbox Code Playgroud)

这意味着每个 js 文件都是一个仅包含一个测试的套件。换句话说,如果前一个失败,我想跳过所有剩余的套件。

MBi*_*ski 6

Intern 文档指定了一个可用于单元测试的 this.skip 方法(https://theintern.io/docs.html#Intern/4/docs/docs%2Fwriting_tests.md/skiping-tests-at-runtime)适用于功能/e2e 测试。

"skipped test":function(){
    this.skip('skipping this');
}
Run Code Online (Sandbox Code Playgroud)

他们还通过配置(https://theintern.io/docs.html#Intern/4/docs/docs%2Fwriting_tests.md/skiping-tests-at-runtime)指定了一个grep-regex选项来跳过测试。