QUnitjQuery 單元測試框架
QUnit 是一個功能強大、易于使用的 JavaScript 單元測試框架。它被 jQuery 項目用于測試代碼和插件,它能夠測試任何通用的 JavaScript 代碼(甚至能夠在服務(wù)器端測試 JavaScript 代碼)。
示例代碼:
test("a basic test example", function() {
ok( true, "this test is fine" );
var value = "hello";
equals( "hello", value, "We expect value to be hello" );
});
module("Module A");
test("first test within module", function() {
ok( true, "all pass" );
});
test("second test within module", function() {
ok( true, "all pass" );
});
module("Module B");
test("some other test", function() {
expect(2);
equals( true, false, "failing test" );
equals( true, true, "passing test" );
});
測試結(jié)果頁面:
評論
圖片
表情
