QUnit Atomic Tests

by Joshua McNeese

HTML

<script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css">
<h1 id="qunit-header">Test Suite</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"></div>

JavaScript

// Don't do this, since test order is not guaranteed
var counter = 0;
 
test("first test", 1, function() {
  counter++;
  equal(counter, 1, "counter should be 1");
});
 
test("second test", 1, function() {
  counter++;
  equal(counter, 2, "counter should be 2");
});
 
test("third test", 2, function() {
  counter++;
  equal(counter, 2, "counter should be 2");
  ok(false, "oops, an error");
});