QUnit
Welcome to MedLibrary.org. For best results, we recommend beginning with the navigation links at the top of the page, which can guide you through our collection of over 14,000 medication labels and package inserts. For additional information on other topics which are not covered by our database of medications, just enter your topic in the search box below:
| Stable release | 1.10.0 / 2012 |
|---|---|
| Written in | JavaScript |
| Type | Test automation framework |
| License | GPL, MIT |
| Website | qunitjs.com |
QUnit is a JavaScript unit testing framework. While heavily used by the jQuery Project for testing jQuery, jQuery UI and jQuery Mobile, it can be used to test any generic JavaScript code. Testing server-side code is possible as well, but QUnit's features are focused on the challenges of testing code in the browser.
QUnit’s assertion methods follow the CommonJS unit testing specification, which was to some degree influenced by QUnit.
Contents |
History
QUnit was originally developed by John Resig as part of jQuery. In 2008 it got its own home, name and API documentation, allowing others to use it for their unit testing as well. At the time it still depended on jQuery. A rewrite in 2009 fixed that, and QUnit now runs completely standalone.
Usage and examples
QUnit uses a set of top-level functions to provide semantic meaning in unit tests:
module(string)- defines a moduletest(string, function)- defines a testok(boolean, string)- validates to true or falseequal(value1, value2, message)- compares two values, using the double-equal comparatordeepEqual(value1, value2, message)- compares two values based on their content, not just their identitystrictEqual(value1, value2, message)- strictly compares two values, using the triple-equal comparator
A basic example would be as follows:
test("a basic test example", function() { ok( true, "this test is fine" ); var value = "hello"; equal( value, "hello", "We expect value to be hello" ); });