michaelleeallen / mocha-junit-reporter

A JUnit XML reporter for mocha.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add rootSuiteTitle to className for Jenkins package grouping

pitgrap opened this issue · comments

We're using this plugin with cypress to repot the results to jenkins. This works really great. But one little thing would make it even better:

We're running multiple testsuites in multiple projects. At the moment they are all displayed as package ".(root)" in Jenkins. It would be nice to get them grouped. We added "rootSuiteTitle" to our options, but this does not help because it ony added to the testsuite name, but not to className.

Example:
These are our reporter options

  "reporterOptions": {
    "mochaFile": "target/surefire-reports/TEST-example-[hash].xml",
    "jenkinsMode": true,
    "rootSuiteTitle": "example"
  },

the xml looks like this

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="11.788" tests="1" failures="0">
  <testsuite name="" timestamp="2020-06-12T11:45:46" tests="0" file="cypress/integration/spec_homepage.js" failures="0" time="0">
  </testsuite>
  <testsuite name="example.homepage" timestamp="2020-06-12T11:45:46" tests="1" failures="0" time="11.788">
    <testcase name="some test" time="11.788" classname="homepage">
    </testcase>
  </testsuite>
</testsuites>

As you can see, the rootSuiteTitle was added to the name, but for jenkins grouping it has to be added to the classname too:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Mocha Tests" time="11.788" tests="1" failures="0">
  <testsuite name="" timestamp="2020-06-12T11:45:46" tests="0" file="cypress/integration/spec_homepage.js" failures="0" time="0">
  </testsuite>
  <testsuite name="example.homepage" timestamp="2020-06-12T11:45:46" tests="1" failures="0" time="11.788">
    <testcase name="some test" time="11.788" classname="example.homepage">
    </testcase>
  </testsuite>
</testsuites>

What do you think. Could this easily be done?

This is related to #136
And yes it would be straightforward to do this.