Your SlideShare is downloading. ×
0
JavaScript Unit Testing Using QUnit
JavaScript Unit Testing Using QUnit
JavaScript Unit Testing Using QUnit
JavaScript Unit Testing Using QUnit
JavaScript Unit Testing Using QUnit
JavaScript Unit Testing Using QUnit
JavaScript Unit Testing Using QUnit
JavaScript Unit Testing Using QUnit
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

JavaScript Unit Testing Using QUnit

2,047

Published on

by Roy Remus Natavio, Exist Software Engineer

by Roy Remus Natavio, Exist Software Engineer

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,047
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. QUnit A JavaScriptTesting Framework
  • 2. OutlineWhat Is QUnit?Creating Tests with QUnitReferences
  • 3. What Is QUnit? QUnit is the testing suite for jQuery scripts and plugins. It doesnt need jQuery scripts to test other javascript codes.
  • 4. Creating Tests with QUnit Download the QUnit script (and the optional QUnit css) Create test script to run against target external javascript Create html file to display test results
  • 5. Sample Function to Testfunction addNumbers(num1, num2) { if (isNaN(num1)) { return "First parameter is NaN"; } else if (isNaN(num2)) { return "Second parameter is NaN"; } else { return num1 + num2; }}
  • 6. Unit Test Scripttest(addNumbers(), function() { equal(addNumbers(1,2), 3, using equal());})
  • 7. The HTML File<html><head> <title>QUnit Test Suite</title> <link rel="stylesheet" type="text/css" media="all"href="qunit.css" /> <script type="text/javascript" src="qunit.js"></script> <!-- Your project file goes here --> <script type="text/javascript" src="sourceScript.js"></script> <!-- Your tests file goes here --> <script type="text/javascript"src="sourceScriptTest.js"></script></head><body> <h1 id="qunit-header">QUnit Test Suite forsourceScript.js</h1> <h2 id="qunit-banner"></h2> <div id="qunit-testrunner-toolbar"></div> <h2 id="qunit-userAgent"></h2> <ol id="qunit-tests"></ol></body></html>
  • 8. References net.tutsplus.com/tutorials/javascript-ajax/how-to-test-your-javascript-code-with-qunit/ docs.jquery.com/QUnit

×