Introduction
TBD
How to Setup QUnit Testing Framework in Maven
TBD
Testcase Guideline
QUnit (1.x)
- Choose
QUnit.test()andQUnit.asyncTest()wisely - Use
QUnit.module()to group test cases, - the module name should follow Java package naming convention, namespace.classname, e.g. info.test.api.core.ChartAppTest
- namespace is mandatory, which contains the project name and test scope, e.g. chart.test
- classname is mandatory, which contains the package path down to the test module, which usually ends up with
Test, e.g.api.core.ChartAppTest - Recover testing page inside
teardown() - One testing file (.js) contains one module at most, and the classname of module should be same as testing file. e.g. TooltipTest.js file contains test module
info.test.api.core.TooltipTest - Each QUnit test closure has a name as description, which starts with
testXXXX, e.g. testXYBindingConvertion. The test name should not contain “.” within it.
Phantomjs (1.9.7):
- Don’t use
innerHTMLproperty ofSVGHTMLElement - Don’t use
Function.prototype.bind. The bind function is a recent addition to ECMA-262, 5th edition; as such it may not be present in all browsers. Add below Polyfill to enable bind keyword.
Polyfill for bind
/*
* add Polyfill for Function.prototype.bind. https://github.com/cujojs/poly
* The bind function is a recent addition to ECMA-262, 5th edition; as such it may not be present in all browsers.
* e.g phantomjs 1.9.7 doesn't support bind keyword.
*/
var isFunction = function (o) {
return typeof o == 'function';
};
var bind,
slice = [].slice,
proto = Function.prototype,
featureMap;
featureMap = {
'function-bind' : 'bind'
};
function has(feature) {
var prop = featureMap[feature];
return isFunction(proto[prop]);
}
// check for missing features
if (!has('function-bind')) {
// adapted from Mozilla Developer Network example at
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind
bind = function bind(obj) {
var args = slice.call(arguments, 1),
self = this,
nop = function () {},
bound = function () {
return self.apply(this instanceof nop ? this : (obj || {}), args.concat(slice.call(arguments)));
};
nop.prototype = this.prototype || {}; // Firefox cries sometimes if prototype is undefined
bound.prototype = new nop();
return bound;
};
proto.bind = bind;
}
Sample Project
Download the sample project, and play it with maven.



