Eze*_*wei 3 javascript unit-testing jasmine jasmine-node
我了解到这种方式是在describe()中循环遍历it()的最佳方式,但是在"spec not found"的情况下它失败了,并且似乎在for循环函数之前就停止了,我想知道我在哪里做错误?
谢谢!
describe('this is my looping test!', function() {
var input = [1,2,3];
var output = [10, 20, 30];
function test_my_times_ten(input, output) {
it('should multiply ' + input + ' by 10 to give ' + output, function() {
expect(input * 10).toEqual(output)
});
}
for(var x = 0; x < input.size; x++) {
test_my_times_ten(input[x], output[x]);
}
});
Run Code Online (Sandbox Code Playgroud)
实际上有人做了这样的聪明的事情,似乎工作!
var testParams = testConfig.testArray;
for (var i = 0; i < testParams.length; i++) {
(function (testSpec) {
it('write your test here', function () {
//test code here
});
})(testParams[i]);
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6821 次 |
| 最近记录: |