QUnitjQuery 单元测试框架
QUnit 是一个功能强大、易于使用的 JavaScript 单元测试框架。它被 jQuery 项目用于测试代码和插件,它能够测试任何通用的 JavaScript 代码(甚至能够在服务器端测试 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" );
}); 
测试结果页面:
评论
