<!DOCTYPE HTML>
<html>
<head>
<!-- 这里引用的是jQuery官网上的Qunit,项目中为了加快下载可以放到本地 -->
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.17.1.css" type="text/css"/>
<script type="text/javascript" src="http://code.jquery.com/qunit/qunit-1.17.1.js"></script>
</head>
<body>
<h1 id="qunit-header">QUnit example</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
<script>
test("a basic test example", function () {
ok(true, "this test is fine");
var value = "hello";
equal(value, "hello", "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);
equal(true, false, "failing test");
equal(true, true, "passing test");
});
</script>
</body>
</html>
这里把test方法写在html文件中

参考:
JS单元测试工具Qunit - 前端组www.qianduanzu.com - 博客园