我正在尝试遍历一些选项并基于 mocha 中的这些选项构建测试。我已经建立了一个简单的概念证明,用于大致基于这个要点进行动态测试:https ://gist.github.com/cybertk/fff8992e12a7655157ed
当我运行 dynamicSuite.addTest() 时,我不断收到错误:“TypeError:test.retries 不是函数”。我无法弄清楚是什么导致了错误。这种在 mocha 中构建测试的方法似乎没有太多文档。
这是代码:
var dynamicSuite = describe('dynamic suite', function() {
this.timeout(10000);
before( function (done) {
var a = ['a', 'b', 'c'];
for(let item of a){
dynamicSuite.addTest(new common.Mocha.Test('test' + item, function(done){
done();
}));
}
done();
});
it('this is needed to make sure tests run', function (done) {
done();
});
after(function(done) {
done();
});
});//end describe test block