您可以使用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