0
Q – UnitJS Unit TestingAlok Guha
Basic components of any UTframework• Test Suite– Spects / Tests• Assertions– Async Tests– Test Runner
What is Q-Unit ?• Unit testing framework build for JQuery.• Additional features– Supports asynchronous testing.– Can break...
Q-Unit Assertions• Just three assertions– equal– ok– deepEqual• Some advanced keywords for asynchronoustesting.
“ok”• The most basic one is ok(), which requires justone argument.• If the argument evaluates to true, the assertionpasses...
“equal”• The equal assertion uses the simple comparisonoperator (==) to compare the actual andexpected arguments.• When th...
“deepEqual”• The deepEqual() assertion can be used just likeequal().• Instead of the simple comparison operator (==), itus...
Test for Synchronous Callbacks• special assertion to define the number ofassertions a test contains in advance.• When the ...
Spyes or Mocks• QUnit doesnt have spies or mocks. But youcan use the Sinon.JS mocking framework• http://sinonjs.org/qunit/...
references• http://qunitjs.com/cookbook/• Mapping from Jasmine.
Q unit
Upcoming SlideShare
Loading in...5
×

Q unit

342

Published on

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

No Downloads
Views
Total Views
342
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
8
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "Q unit"

  1. 1. Q – UnitJS Unit TestingAlok Guha
  2. 2. Basic components of any UTframework• Test Suite– Spects / Tests• Assertions– Async Tests– Test Runner
  3. 3. What is Q-Unit ?• Unit testing framework build for JQuery.• Additional features– Supports asynchronous testing.– Can break code into modules.– Support test timeouts.
  4. 4. Q-Unit Assertions• Just three assertions– equal– ok– deepEqual• Some advanced keywords for asynchronoustesting.
  5. 5. “ok”• The most basic one is ok(), which requires justone argument.• If the argument evaluates to true, the assertionpasses, otherwise, it fails.• In addition, it accepts a string to display as amessage in the test results.Syntax : ok( truthy [, message ] )ok( true, "true succeeds" );
  6. 6. “equal”• The equal assertion uses the simple comparisonoperator (==) to compare the actual andexpected arguments.• When they are equal, the assertion passes;otherwise, it fails .Syntax : equal( actual, expected [, message ] )equal( 0,0,”Yess !! 0 is equal to 0” );
  7. 7. “deepEqual”• The deepEqual() assertion can be used just likeequal().• Instead of the simple comparison operator (==), ituses the more accurate comparison operator (===).• When they are (deep)equal, the assertion passes;otherwise, it fails .Syntax : deepEqual( actual, expected [, message ] )deepEqual( 0,0,”Yess !! 0 is equal to 0” );
  8. 8. Test for Synchronous Callbacks• special assertion to define the number ofassertions a test contains in advance.• When the test completes without the correctnumber of assertions, it will fail, no matterwhat result the other assertions.
  9. 9. Spyes or Mocks• QUnit doesnt have spies or mocks. But youcan use the Sinon.JS mocking framework• http://sinonjs.org/qunit/• http://blog.building-blocks.com/javascript-unit-testing-with-qunit-and-sinon-js• http://cjohansen.no/en/javascript/using_sinon_js_with_qunit
  10. 10. references• http://qunitjs.com/cookbook/• Mapping from Jasmine.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×