michaelleeallen/mocha-junit-reporter

Shared classname between all tests in a testsuite

jpie opened this issue · 6 comments

jpie commented

Regarding the enhancements provided in #51, is there any way to make the classname unique the testsuite? Here is an example mocha test:

describe('Get all endpoints', () => {
    it('should render the map page', (done) => {
...
    })
    it('should render faq page', (done) => {
...
})

When setting testCaseSwitchClassnameWithName = true This is the result:

<testsuite name="Get all endpoints" timestamp="2018-11-20T19:59:09" tests="12"  failures="4" time="0.4750000000000001">
    <testcase name="should render the map page" time="0.07" classname="Get all endpoints should render the map page">
    </testcase>
    <testcase name="should render faq page" time="0.02" classname="Get all endpoints should render faq page">
    </testcase>
...

It seems that the classname returns a concatenation of the testsuite name and the testcase name. Is there anyway to set the classname to the testsuite name in order to group the rest of the tests so that they all follow under one classname?

@jpie can you provide an example of what you would like to see?

jpie commented

Below is an example:

<testsuite name="Get all endpoints" timestamp="2018-11-20T19:59:09" tests="12"  failures="4" time="0.4750000000000001">
    <testcase name="should render the map page" time="0.07" classname="Get all endpoints">
    </testcase>
    <testcase name="should render faq page" time="0.02" classname="Get all endpoints">
    </testcase>

The only difference is the classname shares the name of the testsuite name. The reason I bring this is up is because it will help clean up test results in JUnit test reporter for jenkins. The test reporter groups the tests by classname.

I think this would have to be a new enhancement. The testCaseSwitchClassnameWithName feature works as intended.

jpie commented

Agreed, I actually did some work on how I think this could work, but didn't want to make a PR until it was acknowledged. I'll make one shortly so you can see what I had in mind.

I'm wondering if maybe there should be one setting like jenkninsMode that will tweak the output so it will be displayed nicely with Jenkins. I guess it can just enable / disable a few other settings but it will probably make the intent a lot clearer and will not require setting obscure settings.

Any updates on if this will be approved? I'm facing this exact problem and the PR should make it a non-issue.