QUnit tests, with queued units
A demo of the Queued unit where QUnit tests are executed in order. See this fiddle (http://jsfiddle.net/axemclion/zwXBx/) for how they are not in order. More details here - http://blog.nparashuram.com/2012/05/running-qunit-tests-sequentially-in.html
by axemclion
HTML
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css">
<script src="https://raw.github.com/gist/2561465/QueuedUnit.js"></script>
<html>
<head>
</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>
<div id = "logger" class = "pass"></div>
</body>
</html>
CSS
#logger{
margin: 10px;
font-size : 10px;
font-family :
}
JavaScript
QUnit.config.autorun = false;
window.setTimeout(function() {
startSampleTests();
nextTest();
}, 100 /*Change this to 10 and see the order in which the test are run*/ );
function startSampleTests() {
queuedModule("Module1");
queuedAsyncTest("Test1", function() {
window.setTimeout(function() {
ok(true, "Test 1, assertion 1");
log("Running Test 1, assertion 1");
start();
stop();
}, 100);
window.setTimeout(function() {
ok(true, "Test 1, assertion 2");
log("Running Test 1, assertion 2");
start();
nextTest();
}, 500);
});
queuedAsyncTest("Test2", function() {
window.setTimeout(function() {
ok(true, "Test 2, assertion 1");
log("Running Test 2, assertion 1");
start();
stop();
}, 200);
window.setTimeout(function() {
ok(true, "Test 2, assertion 2");
log("Running Test 2, assertion 2");
start();
nextTest();
}, 500);
});
queuedModule("Module2");
queuedAsyncTest("Test3", function() {
window.setTimeout(function() {
ok(true, "Test 3, assertion 1");
log("Running Test 3, assertion 1");
start();
stop();
}, 10);
window.setTimeout(function() {
ok(true, "Test 3, assertion 2");
log("Running Test 3, assertion 2");
start();
nextTest();
}, 500);
});
queuedAsyncTest("Test4", function() {
window.setTimeout(function() {
ok(true, "Test 4, assertion 1");
log("Running Test 4, assertion 1");
start();
stop();
}, 10);
window.setTimeout(function() {
ok(true, "Test 4, assertion 2");
log("Running Test 4, assertion 2");
start();
nextTest();
}, 700);
...