32-解决方案
18.8.2 解决方案
QUnit提供URL过滤来选择运行的测试,这在与模块组合时效果最好。可以在测试套件URL后附加带有模块名称的查询字符串,只运行指定模块中的测试。例如, test.html?validation 将运行模块 validation 中的所有测试:
// test.html?validation - 只运行验证模块
// test.html?validation&tooltip - 验证和工具提示模块
// test.html?!validation - 排除验证模块
// test.html?test 3 - 只运行"test 3",URL将显示为test.html?test%203
module("validation");
test("test 1", function () {
ok(true, "bool succeeds");
});
test("test 2", function () {
equals(5, 5.0, "equals succeeds");
});
module("tooltip");
test("test 3", function () {
same(true, 3 == 3, "same succeeds");
});
test("test 4", function () {
ok(false, "bool fails");
});
module("other");
test("test 5", function () {
equals(3, 5, "equals fails");
});