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 code into modules.– Support test timeouts.
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, 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" );
“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” );
“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” );
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.
references• http://qunitjs.com/cookbook/• Mapping from Jasmine.
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.