Home Ajax Jquery Developing a program to test

Related Tutorials


 
 

Share on Google+Share on Google+

Developing a program to test

Advertisement
This page discusses - Developing a program to test

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.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 18, 2011

Related Tutorials

Discuss: Developing a program to test  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com