Created
June 10, 2012 17:54
-
-
Save greenido/2906762 to your computer and use it in GitHub Desktop.
Example for Unit testing on the client with QUnit - help for: http://stackoverflow.com/questions/10970719/qunit-cant-recognize-more-than-one-test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<title>Example for Unit testing on the client</title> | |
<meta name="author" content="Ido Green"> | |
<link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css" type="text/css" media="screen" /> | |
<script src="http://code.jquery.com/jquery-latest.js"></script> | |
<script src="http://code.jquery.com/qunit/git/qunit.js"></script> | |
<script> | |
$(document).ready(function(){ | |
QUnit.log = function(result, message) { | |
if (window.console && window.console.log) { | |
window.console.log(result +' :: '+ message); | |
} | |
} | |
module("Basic Unit Test"); | |
test("Sample test", function() { | |
expect(1); | |
equal(divide(4,2),2, 'Expected 2 as the result, result was ' + | |
divide(4,2)); | |
}); | |
test("Test two", function() { | |
expect(1); | |
equal(divide(8,2),2,'Expected 4 as the result, result was ' + | |
divide(8,2)); | |
}); | |
function divide(a,b){ | |
return a / b; | |
} | |
}); | |
</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> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment