Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Change to xml format loses nesting #3

Closed
DexterTheDragon opened this issue Dec 11, 2015 · 1 comment
Closed

Change to xml format loses nesting #3

DexterTheDragon opened this issue Dec 11, 2015 · 1 comment

Comments

@DexterTheDragon
Copy link
Contributor

Given the following jasmine file

describe('ClassA', function() {
    it('returns true', function() {
        <snip>
    });
});
describe('ClassB', function() {
    it('returns true', function() {
        <snip>
    });
});

The old xml format would result in the following.

<testsuites>                                                                                                                                         
  <testsuite tests="1" failures="0" errors="0" name="ClassA">                                                
    <testcase name="returns true"/>                                                                                                         
  </testsuite>                                                                                                                                       
  <testsuite tests="1" failures="0" errors="0" name="ClassB">                                                
    <testcase name="returns true"/>                                                                                                        
  </testsuite>                                                                                                                                       
</testsuites>

Which when viewed using the jenkins junit plugin creates a hierarchy like

ClassA
    returns true
ClassB
    returns true

The format that 1.0 creates is

<testsuites>                                                                                                                                         
  <testsuite name="Jasmine Suite" tests="2" failures="0" errors="0">                                                                               
    <testcase name="returns true"/>                                                                                                         
    <testcase name="returns true"/>
  </testsuite>                                                                                                                                       
</testsuites>

Which leaves you with a hierarchy like

Jasmine Suite
    returns true
    returns true

I believe the proper way to do it with junit xml is to add the classname attribute

<testsuites>                                                                                                                                         
  <testsuite name="Jasmine Suite" tests="2" failures="0" errors="0">                                                                               
    <testcase classname="ClassA" name="returns true"/>                                                                                                         
    <testcase classname="ClassB" name="returns true"/>
  </testsuite>                                                                                                                                       
</testsuites>
@slackersoft
Copy link
Member

Thanks for the catch.

The two options I can see for this are to either put the fullName of the spec (including all parent describes) in the name attribute or taking what we used to have as the name of the suite (fullName with the name of the test removed) and put that all in classname.

My concern with the second is that with nested describes or just a longer description, the classname could end up with whitespace in it, which seems weird to me for an attribute called classname.

I would be happy to review a pull request that implements either of these solutions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants