2012-02-23 88 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.