JUnitFormatter does not put required name attribute in testsuite root element #477

Closed
ericmaxwell2003 opened this Issue Mar 11, 2013 · 3 comments

Comments

Projects
None yet
3 participants
Contributor

ericmaxwell2003 commented Mar 11, 2013

Unless I'm mistaken, the name attribute inside of the root element, testsuite, is required by the maven surefire-report-plugin and this is not being supplied by the cucumber-jvm core cucumber.runtime.formatter.JUnitFormatter class.

The problem is that the surefire-report-plugin cannot build the surefire report site off the generated Cucumber JUnit report, because an NPE is thrown inside of
org.apache.maven.plugins.surefire.report.ReportTestSuite.setFullClassName(...) when it is passed a null value for the attribute.

I encountered this issue when running mvn:site, using the JUnit report created by the Cucumber test runner.

Example:
Here is my test runner class.

@RunWith(Cucumber.class)
@Cucumber.Options(
        format = {
        "pretty", // stdout format
        "junit:target/surefire-reports/TEST-foo.pack.age.CucumberBddTest.xml"
        })
public class CucumberBddTest {

}

Notice, I put the output of the Cucumber JUnit report to the same place as the original surefire version. This causes the original to be replaced so that only the prettier Cucumber JUnit report is reported on. This works because the Cucumber version is generated after the original surefire one is generated. Not sure if there is a better way to do this.
...

// It generates something like the following
TEST-foo.pack.age.CucumberBddTest.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<testsuite failures="0" tests="70">
<testcase classname="..." name="..." time="0.525339">
<system-out><![CDATA[Given i plan to yada yada.................................passed
When i yada yada...........................................passed
Then it does indeed yada yada...................................passed
]]></system-out>
</testcase>
...
</testsuite>

Notice that the testsuite element contains no name attribute. This is the issue.

I am new to cucumber and cucumber-jvm, so perhaps I'm using this incorrectly, but if this is a valid issue, I do already have a patch that I made and tested locally. My patch will add the name and it also rolls up the total testsuite time and number of skipped tests. The later two aren't required, but they weren't hard to add so I threw them in. I could send them to the cucumber-jvm team for review if interested.

karaaie commented Mar 12, 2013

This one seems highly related to my issue, #468, my issue also boils down to the fact that the JUnitReporter/Formater behaves in that particular way. I'm not part of the team but I'm curious about your patch, can I try it out and see if it solves my issues as well?

Owner

aslakhellesoy commented Mar 12, 2013

@ericmaxwell2003 sounds good. Looking forward to your pull request.

@ericmaxwell2003 ericmaxwell2003 added a commit to ericmaxwell2003/cucumber-jvm that referenced this issue Mar 12, 2013

@ericmaxwell2003 ericmaxwell2003 Updates for Issue #477 - JUnitFormatter does not put required name at…
…tribute in testsuite root element.
be7ec10

@ericmaxwell2003 ericmaxwell2003 added a commit to ericmaxwell2003/cucumber-jvm that referenced this issue Mar 12, 2013

@ericmaxwell2003 ericmaxwell2003 Updates for issue #477, wrap exceptions which may be thrown in sumTim…
…es and rethrow
f9cad32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment