gpt4 book ai didi

testing - CasperJS 中的 "test.begin()"函数是什么意思?

转载 作者:行者123 更新时间:2023-11-28 19:41:21 25 4
gpt4 key购买 nike

我不太了解函数test.begin(String description, Number planned, Function suite)。参数 Number planed 有什么用?

最佳答案

Number planned 是您希望测试的断言 的数量。这完全是可选的,并且可以被认为是对您的测试脚本实际上已经完全完成的健全性检查。

docs states :-

The planned argument is especially useful in case a given test script is abruptly interrupted leaving you with no obvious way to know it and an erroneously successful status.

一个例子:-

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

这个测试实际上会失败,因为我已经定义了 3 个计划的断言,但只有 2 个成功了(因为只有 2 个断言)。

关于testing - CasperJS 中的 "test.begin()"函数是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26943351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com