JunitXml记者问题

时间:2018-07-10 06:00:45

标签: xml junit jasmine protractor report

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

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

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

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

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

对于每个运行,我都需要单独的报告。有没有办法做到这一点?

一种方法是在每次运行后将报告保存到另一个位置,但是我不知道该怎么做。

有帮助吗?

1 个答案:

答案 0 :(得分:0)

假设您正在使用JUnitXmlReporter中的jasmine-reporters,则可以使用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);
    });
}

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