Home Ajax Jquery Using the QUnit to test jQuery application

Related Tutorials


 
 

Share on Google+Share on Google+

Using the QUnit to test jQuery application

Advertisement
This page discusses - Using the QUnit to test jQuery application

Using the QUnit to test jQuery application

     

Using the QUnit to test jQuery application

Using Qunit , testing of JQuery become very easy and efficient.

Consider the following Code :

 <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>

For Complete code, output and live demo  click here

To use QUnit, you have to include its ' qunit.js ' and ' qunit.css ' files in your web page as :

<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>

For Downloading  'qunit.js' click here

For Downloading 'qunit.css' click here

If you are Downloading it , then you need not to give url of these. You just need to give the path of these saved file as :

<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />

<script type="text/javascript" src="qunit.js"></script>

In the above case ,file should be saved in the same folder in which web page is stored.

The description of the methods use in the above code :

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: Using the QUnit to test jQuery application  

Post your Comment


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