Developing a program to test
Developing a program to test
Given below program is to test the script :
Qunit.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js">
</script>
<link rel="stylesheet" href="http://github.com/jquery/qunit
/raw/master/qunit/qunit.css"
type="text/css" media="screen"/>
<script type="text/javascript" src="http://github.com/jquery
/qunit/raw/master/qunit/qunit.js"></script>
<script>
$(document).ready(function(){
test("a basic test example", function() {
ok( true, "this test is fine" );
var value = "hello";
equals( "hello", value, "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);
equals( true, false, "failing test" );
equals( true, true, "passing test" );
});
});
</script>
</head>
<body>
<h1 id="qunit-header">QUnit example</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
</body>
</html> |
Description of the program :
For explanation of QUnit methods click here.
Description of the CSS class used in html tags :
The #qunit-header element should contain the name of the testsuite, and won't
be modified by QUnit. The #qunit-banner element will set to show up as red if a
test failed, green if all tests passed. The #qunit-userAgent elements is set to
display the navigator.userAgent property. The #qunit-tests element will be used
as a container for the test results.
The #qunit-fixture element can be used to provide and manipulate test markup,
and will be automatically reset after each test.
Output :
Download Source Code
Click here to see online
demo
Learn from experts! Attend
jQuery Training classes.