Qunit > 基礎
already has qunit and its css linked already. sample test provided. useful as a template.
by s_hiroshi
HTML
<link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css">
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<h1 id="qunit-header">Unit Tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture"></div>
JavaScript
test("Infinity Test", function() {
ok(true, "ok");
var x = 10/0;
var pow = function() {
return Math.pow(x, 2);
}
same(pow(2), Infinity, "this is Infinity"); // passed
same(x, NaN, "this is Nan"); // fail
});