您可以使用callbacks of QUnit來實現。他們正在測試的執行過程中被稱爲在幾個不同點(每次測試之前例如,每一個模塊後,...)
這裏是我的測試套件的例子:
QUnit.begin = function() {
console.log('####');
};
QUnit.testStart = function(test) {
var module = test.module ? test.module : '';
console.log('#' + module + " " + test.name + ": started.");
};
QUnit.testDone = function(test) {
var module = test.module ? test.module : '';
console.log('#' + module + " " + test.name + ": done.");
console.log('####');
};
它把這個在名爲helper.js
的文件中,並將其包含在測試index.html頁面中。
它產生的輸出是這樣的:
####
#kort-Availability Includes: started.
#kort-Availability Includes: done.
####
#kort-UrlLib Constructor: started.
#kort-UrlLib Constructor: done.
####
#kort-UrlLib getCurrentUrl: started.
#kort-UrlLib getCurrentUrl: done.
####
來源
2013-02-11 14:05:45
Odi
請確保避免您運行測試的場景,然後您需要閱讀日誌以瞭解它們是否通過。這繞過了自動化測試的大部分好處!如果日誌只是提供額外的信息,那麼沒有問題。 – 2015-08-07 15:19:40