【发布时间】:2021-05-13 13:17:49
【问题描述】:
如何在 Protractor 中查找通过、失败的测试用例总数?
请推荐用于问题陈述的 npm 包
【问题讨论】:
标签: protractor reporting
如何在 Protractor 中查找通过、失败的测试用例总数?
请推荐用于问题陈述的 npm 包
【问题讨论】:
标签: protractor reporting
好的,如果您希望描述失败的次数,您可以在配置中的 onPrepare 中添加此代码
onPrepare() {
jasmine.getEnv().addReporter({
suites: [],
jasmineStarted: function(suiteInfo) {
let jasmineSuites = jasmine.getEnv().topSuite();
for (let suite of jasmineSuites.children) {
this.suites.push({
suite: suite.description,
status: 'pass',
});
}
},
specDone: function(spec) {
if (spec.status === 'failed') {
let suiteName = spec.fullName.replace(' ' + spec.description, '');
this.suites.find(item => item.suite === suiteName).status = 'failed'
}
},
jasmineDone: function(result) {
let failed = this.suites.filter(item => item.status === 'failed')
console.log('**************************************************')
console.log(`${failed.length} of ${this.suites.length} describe(s) failed`)
console.log('**************************************************')
},
})
}
【讨论】: