【问题标题】:How to find total passed, failed test cases in Protractor?如何在量角器中找到全部通过、失败的测试用例?
【发布时间】:2021-05-13 13:17:49
【问题描述】:

如何在 Protractor 中查找通过、失败的测试用例总数?

请推荐用于问题陈述的 npm 包

【问题讨论】:

    标签: protractor reporting


    【解决方案1】:

    原生 Jasmine 框架有什么问题?

    【讨论】:

    • 感谢您的回复,我不想要单独的它块级通过/失败报告,我想要整体脚本/测试用例失败/描述块失败。前任;如果我们有 100 个要执行的测试脚本并且我们有 80 个失败 20 个通过案例,那么我正在寻找能够满足需求的报告插件
    【解决方案2】:

    好的,如果您希望描述失败的次数,您可以在配置中的 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('**************************************************')
                },
            })
    }
    

    它会在你的控制台中产生这个输出

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多