"test.begin()"函数在CasperJS中意味着什么?

fir*_*fly 13 testing parameters methods casperjs

我不太了解这个功能test.begin(String description, Number planned, Function suite).参数Number planed是什么?

Rip*_*ppo 17

Number plannedasserts您期望测试的数量.这完全optional可以被认为是一个完整性完全完成的测试脚本的完整性检查.

文件规定: -

如果给定的测试脚本突然中断,计划的参数特别有用,让您没有明显的方法来了解它并且错误地成功.

一个例子:-

casper.test.begin('when testing foo', 3, function() {
    test.assertEquals(1 === 1, '1 equals 1');
    test.assertEquals(5 === 5, '5 equals 5');
    test.done();
});
Run Code Online (Sandbox Code Playgroud)

这个测试实际上会失败,因为我已经定义3 planned asserts但只有2个成功(因为只有2个断言).