Introduction to Unit Testing using QUnit
Upcoming SlideShare
Loading in...5
×
 

Introduction to Unit Testing using QUnit

on

  • 297 views

An Introduction to Unit testing, what it is, why is it needed and how it is done. Using QUnit.

An Introduction to Unit testing, what it is, why is it needed and how it is done. Using QUnit.

Statistics

Views

Total Views
297
Views on SlideShare
297
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Introduction to Unit Testing using QUnit Introduction to Unit Testing using QUnit Presentation Transcript

  • Software Testing by Varun Vaddiparty
  • ● User Interface Development ● Source Code ● Quality Assurance (software testing)
  • Need for software testing: ● Meets the requirements ● works as expected ● satisfies the need of customer Different Methods: ● Static Testing ● Dynamic Testing
  • Unit Testing ● Verify the functionality of specific section of the code. ● Usually at the function level. ● To ensure that a specific function is working as expected.
  • Qunit ● A Javascript unit testing framework. ● It can be used to test any generic Javascript code. ● You can test your code in the browser itself.
  • A minimal Qunit test setup.
  • The contents of test.js :
  • Result of the test:
  • Asserting Results ● Essential elements of any unit tests. ● You express the result expected and have the testing framework compare them to the actual values that the functions output. Qunit provides three assertions: ● ok() ● equal() ● deepEqual()
  • ok() ● ok(truthy,[message]) ● most basic assertion ● requires only one argument, in addition you can send a string to show as a message examples: ok(true,”true succeeds”); ok(1==1,”test passed”);
  • equal() ● equal(actual,expected,[message]); ● compares your expected value with the actual value examples: equal(1,1,”1 equals 1, test passes”); equal(“”,0,”zero equals empty, test passes”);
  • deepEqual() ● deepEqual(actual,expected,[message]); ● can be used just like equal, is a better choice ● uses more accurate comparison operator (===) instead of simple (==) examples: deepEqual(0,””,”test fails, zero not equal to empty”);
  • expect() ● used to check whether all the assertions have been executed or not
  • asyncTest() ● used for asynchronous testing Practical Example:
  • Thank You