【问题标题】:JunitXml reporter issuesJunitXml 报告器问题
【发布时间】:2018-07-10 06:00:44
【问题描述】:

我正在使用 Jasmine 和量角器来运行单元测试。

我有运行三个规范文件的测试套件

suites:{
r = ['a.js', 'b.js', 'c.js']
},

我计划运行 Jenkins 并需要 JunitXml 报告。

问题是该套件将根据不同的用例总共运行四次。

我需要为每次运行提供单独的报告。有没有办法做到这一点?

一种方法是在每次运行后将报告保存到另一个位置,但我想不出办法。

有什么帮助吗?

【问题讨论】:

    标签: xml junit jasmine protractor report


    【解决方案1】:

    假设您使用jasmine-reporters 中的JUnitXmlReporter,您可以使用filePrefixmodifiySuiteName 来创建不同的文件或套件名称。您没有说运行之间的区别是什么,但multi capabilities 的文档显示了如何根据浏览器更改名称:

    onPrepare: function() {
        var jasmineReporters = require('jasmine-reporters');
    
        // returning the promise makes protractor wait for the reporter config before executing tests
        return browser.getProcessedConfig().then(function(config) {
            // you could use other properties here if you want, such as platform and version
            var browserName = config.capabilities.browserName;
    
            var junitReporter = new jasmineReporters.JUnitXmlReporter({
                consolidateAll: true,
                savePath: 'testresults',
                // this will produce distinct xml files for each capability
                filePrefix: browserName + '-xmloutput',
                modifySuiteName: function(generatedSuiteName, suite) {
                    // this will produce distinct suite names for each capability,
                    // e.g. 'firefox.login tests' and 'chrome.login tests'
                    return browserName + '.' + generatedSuiteName;
                }
            });
            jasmine.getEnv().addReporter(junitReporter);
        });
    }
    

    您可能可以对其进行编辑以满足您的需求,或者在有关套件如何运行以及运行之间发生哪些变化的问题中添加更多详细信息。

    【讨论】:

    • 我通过将当前日期和时间添加到报告文件前缀来解决了这个问题。
    猜你喜欢
    • 2015-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-12
    • 1970-01-01
    相关资源
    最近更新 更多