2012-02-23 55 views

回答

4

总结所有的函数内部测试。

当您准备好运行测试时调用该函数。

如果你想在QUnit完成后重新运行测试,然后调用一个函数,如'rerunQUnitTest'。

var runAllTest = function(){ 
    test("test 1", function(){ 
     var a = true; 
     equal(a, true, "function a should return false"); 
    }); 
}; 
// call rerunQUnitTest to reset and run your tests again. 
var rerunQUnitTest = function(){ 
    QUnit.reset(); // should clear the DOM 
    QUnit.init(); // resets the qunit test environment 
    QUnit.start(); // allows for the new test to be captured. 
    runAllTest(); // runs your functions that has all the test wrapped inside. 
}; 
runAllTest(); // auto runs your tests.