我正在使用 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文件都是一个只包含一个测试的套件。换句话说,这就像我想跳过所有剩余的套件,如果前一个套件失败的话。
最佳答案
实习生文档指定了一个 this.skip 方法,该方法可用于单元测试 ( https://theintern.io/docs.html#Intern/4/docs/docs%2Fwriting_tests.md/skipping-tests-at-runtime ),它也适用于功能/e2e 测试。
"skipped test":function(){
this.skip('skipping this');
}
他们还指定了一个 grep-regex 选项,用于通过配置 (https://theintern.io/docs.html#Intern/4/docs/docs%2Fwriting_tests.md/skipping-tests-at-runtime) 跳过测试。
关于javascript - 实习生功能测试 : skip a suite/test,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33629164/