Allure: How do I customize the test report to writ

2019-07-13 16:11发布

问题:

In the allure test report, the overview page lists Defects, Xunit, Behaviors, and Defects. I would like to change "Xunit" to "Browsers" since my test suites are specific browsers. Is it possible to do this dynamically so it's changed for every test report generated?

Thanks

回答1:

In general changing your xUnit tab name to something else is not a good practice. For example you may want to add other suite type in the future (not corresponding to browser name).

Allure has an new cool feature to customize your report (not documented yet). To make such customization you should write your own report plugin.

First of all create a new project and add the following dependency to your pom.xml:

<dependency>
    <groupId>ru.yandex.qatools.allure</groupId>
    <artifactId>allure-report-plugin-api</artifactId>
    <version>1.4.16</version>
</dependency>

Then create a sample plugin:

@Plugin.Name("browsersXunit")
public class BrowsersXUnitPlugin extends DefaultTabPlugin {

    @Override
    public void process(AllureTestCase data) {
        //you are no need to process this data so keep it empty
    }
}

Finally add the following file to your resources:

your/plugin/package/BrowsersXUnitPlugin/script.js:

/*global angular*/
(function() {
    "use strict";
    var module = angular.module('allure.browsersXunit', []);
    module.config(function($stateProvider, allureTabsProvider) {
        //here you can perform some javascript magic 
    });
})();

It is the beta version of plugin system and some API can be changed in the future. For example take a look at the following repository.



回答2:

I would say the only way to do that is to attach a custom translation file like this one. See this commit for details.



标签: allure