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

时间:2015-11-10 11:41:32

标签: 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();
            },
        };
    });
});

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

1 个答案:

答案 0 :(得分:3)

实习生文档指定了一个可用于单元测试的this.skip方法(https://theintern.github.io/intern/#skipping-tests),该方法也适用于功能/ e2e测试。

"skipped test":function(){
    this.skip('skipping this');
}

他们还指定了一个grep-regex选项,用于通过配置(https://theintern.github.io/intern/#common-config)跳过测试。