Skip to content

[JENKINS-1233] JUnit Test Report parsed incorrectly #780

Closed

Description

@jenkins-infra-bot

The current version (1.171) has a problem parsing the following JUnit report file:

<?xml version="1.0" encoding="UTF-8" ?>
<testsuites>
 <testsuite errors="0" failures="0"
         hostname="archbuild" id="0"
       name="StudioAllTests"
       package="test.infor.clearux.studio.integration" tests="456"           
time="107.824" timestamp="2008-01-23T10:49:26">

     <testcase classname="test.foo.bar.DefaultIntegrationTest"
name="experimentsWithJavaElements" time="0.0" />
     <testcase classname="test.foo.bar.BundleResolverIntegrationTest"
name="testGetBundle" time="0.0" />
     <testcase classname="test.foo.bar.BundleResolverIntegrationTest"
name="testGetBundleLocation" time="0.656" />
     <testcase classname="test.foo.bar.ProjectSettingsTest"
name="testNatureAddition" time="0.125" />
     <testcase classname="test.foo.bar.ProjectSettingsTest"
name="testNatureRemoval" time="0.11" />
 </testsuite>
</testsuites>

The file is produces using the Junit ant task. Note, in this file the
element is omitted for clarity.

In 1.132 this file will produce this kind of output:

<?xml version='1.0' encoding='UTF-8'?>
<result>
 <suites>
   <suite>
     <cases>
       <case>
         <className>test.foo.bar.DefaultIntegrationTest</className>
         <testName>experimentsWithJavaElements</testName>
         <failedSince>0</failedSince>
       </case>
       <case>
         <className>test.foo.bar.BundleResolverIntegrationTest</className>
         <testName>testGetBundle</testName>
         <failedSince>0</failedSince>
       </case>
       <case>
         <className>test.foo.bar.BundleResolverIntegrationTest</className>
         <testName>testGetBundleLocation</testName>
         <failedSince>0</failedSince>
       </case>
       <case>
         <className>test.foo.bar.ProjectSettingsTest</className>
         <testName>testNatureAddition</testName>
         <failedSince>0</failedSince>
       </case>
       <case>
         <className>test.foo.bar.ProjectSettingsTest</className>
         <testName>testNatureRemoval</testName>
         <failedSince>0</failedSince>
       </case>
     </cases>
   </suite>
 </suites>
</result>

In version 1.171 this will look like this :

<?xml version='1.0' encoding='UTF-8'?>
<result>
 <suites>
   <suite>
     <name>(test.foo.bar.AllTests.xml)</name>
     <duration>101.90081</duration>
     <cases>
       <case>
         <duration>0.0</duration>
         <className>(test.foo.bar.AllTests.xml)</className>
         <testName>experimentsWithJavaElements</testName>
         <failedSince>0</failedSince>
       </case>
       <case>
         <duration>0.016</duration>
         <className>(test.foo.bar.AllTests.xml)</className>
         <testName>testGetBundle</testName>
         <failedSince>0</failedSince>
       </case>
       <case>
         <duration>0.797</duration>
         <className>(test.foo.bar.AllTests.xml)</className>
         <testName>testGetBundleLocation</testName>
         <failedSince>0</failedSince>
       </case>
       <case>
         <duration>0.125</duration>
         <className>(test.foo.bar.AllTests.xml)</className>
         <testName>testNatureAddition</testName>
         <failedSince>0</failedSince>
       </case>
       <case>
         <duration>0.093</duration>
         <className>(test.foo.bar.AllTests.xml)</className>
         <testName>testNatureRemoval</testName>
         <failedSince>0</failedSince>
       </case>
     </cases>
   </suite>
 </suites>
 <duration>101.90081</duration>
</result>

Note, how the new version is using the file name surrounded with parentheses
instead of the actual test class.

I have posted the question on the mail list and Kohsuke suggested to file a
defect. Here is the mailing list link :
https://hudson.dev.java.net/servlets/ReadMsg?list=users&msgNo=6603

  • Stefan

Originally reported by s_baramov, imported from: JUnit Test Report parsed incorrectly
  • status: Closed
  • priority: Major
  • component(s): junit-plugin
  • resolution: Fixed
  • resolved: 2008-02-02T22:35:19+00:00
  • votes: 0
  • watchers: 0
  • imported: 2025-11-26
Raw content of original issue

The current version (1.171) has a problem parsing the following JUnit report file:

<?xml version="1.0" encoding="UTF-8" ?> <testsuites> <testsuite errors="0" failures="0" hostname="archbuild" id="0" name="StudioAllTests" package="test.infor.clearux.studio.integration" tests="456" time="107.824" timestamp="2008-01-23T10:49:26">

<testcase classname="test.foo.bar.DefaultIntegrationTest" name="experimentsWithJavaElements" time="0.0" /> <testcase classname="test.foo.bar.BundleResolverIntegrationTest" name="testGetBundle" time="0.0" /> <testcase classname="test.foo.bar.BundleResolverIntegrationTest" name="testGetBundleLocation" time="0.656" /> <testcase classname="test.foo.bar.ProjectSettingsTest" name="testNatureAddition" time="0.125" /> <testcase classname="test.foo.bar.ProjectSettingsTest" name="testNatureRemoval" time="0.11" /> </testsuite> </testsuites>

The file is produces using the Junit ant task. Note, in this file the <properties> element is omitted for clarity.

In 1.132 this file will produce this kind of output:

<?xml version='1.0' encoding='UTF-8'?> <result> <suites> <suite> <cases> <case> <className>test.foo.bar.DefaultIntegrationTest</className> <testName>experimentsWithJavaElements</testName> <failedSince>0</failedSince> </case> <case> <className>test.foo.bar.BundleResolverIntegrationTest</className> <testName>testGetBundle</testName> <failedSince>0</failedSince> </case> <case> <className>test.foo.bar.BundleResolverIntegrationTest</className> <testName>testGetBundleLocation</testName> <failedSince>0</failedSince> </case> <case> <className>test.foo.bar.ProjectSettingsTest</className> <testName>testNatureAddition</testName> <failedSince>0</failedSince> </case> <case> <className>test.foo.bar.ProjectSettingsTest</className> <testName>testNatureRemoval</testName> <failedSince>0</failedSince> </case> </cases> </suite> </suites> </result>

In version 1.171 this will look like this :

<?xml version='1.0' encoding='UTF-8'?> <result> <suites> <suite> <name>(test.foo.bar.AllTests.xml)</name> <duration>101.90081</duration> <cases> <case> <duration>0.0</duration> <className>(test.foo.bar.AllTests.xml)</className> <testName>experimentsWithJavaElements</testName> <failedSince>0</failedSince> </case> <case> <duration>0.016</duration> <className>(test.foo.bar.AllTests.xml)</className> <testName>testGetBundle</testName> <failedSince>0</failedSince> </case> <case> <duration>0.797</duration> <className>(test.foo.bar.AllTests.xml)</className> <testName>testGetBundleLocation</testName> <failedSince>0</failedSince> </case> <case> <duration>0.125</duration> <className>(test.foo.bar.AllTests.xml)</className> <testName>testNatureAddition</testName> <failedSince>0</failedSince> </case> <case> <duration>0.093</duration> <className>(test.foo.bar.AllTests.xml)</className> <testName>testNatureRemoval</testName> <failedSince>0</failedSince> </case> </cases> </suite> </suites> <duration>101.90081</duration> </result>

Note, how the new version is using the file name surrounded with parentheses instead of the actual test class.

I have posted the question on the mail list and Kohsuke suggested to file a defect. Here is the mailing list link : https://hudson.dev.java.net/servlets/ReadMsg?list=users&msgNo=6603

  • Stefan
  • environment: Platform: All, OS: All

Activity

  1. jenkins-infra-bot commented on Feb 2, 2008

    @jenkins-infra-bot
    Author
    kohsuke:
    • Original comment link
    • Raw content of original comment:

      Incorporated changes in 1.179.

    Incorporated changes in 1.179.

  2. jenkins-infra-bot commented on Feb 5, 2008

    @jenkins-infra-bot
    Author
    s_baramov:
    • Original comment link
    • Raw content of original comment:

      Tested 1.179 and it worked just fine. Many thanks to the Hudson team for the quick fix.

    Tested 1.179 and it worked just fine. Many thanks to the Hudson team for the
    quick fix.

  3. jenkins-infra-bot commented on Apr 3, 2008

    @jenkins-infra-bot
    Author
    scm_issue_link:
    • Original comment link
    • Raw content of original comment:

      Code changed in hudson User: kohsuke Path: /hudson/hudson/main/core/src/main/java/hudson/tasks/junit/SuiteResult.java (1.14) /hudson/hudson/main/core/src/main/java/hudson/tasks/junit/TestResult.java (1.18) /hudson/hudson/main/core/src/main/java/hudson/tasks/junit/CaseResult.java (1.15) /hudson/hudson/main/core/src/test/java/hudson/tasks/junit/SuiteResultTest.java (1.2) /hudson/hudson/main/core/src/test/resources/hudson/tasks/junit/junit-report-1472.xml (1.1) http://fisheye5.cenqua.com/changelog/hudson/?cs=MAIN:kohsuke:20080403080351

      Log: fixed issue #1472. For us to keep sanity in parsing JUnit XML, I think we have to break the earlier fix we made for JBoss guys. See http://www.nabble.com/difference-in-junit-publisher-and-ant-junitreport-td12265700.html#a12265700 for more about that. The problem is that the fix for issue #1233 is at odds with this XML that JBoss uses, when it comes to whether <testsuite>/@name should win or <testcase>/@classname wins. JUnit XML from JBoss was said to be written by a custom formatter, so I think we can be justified in breaking that in favor of #1233 (although junit XSLT apparently handles that correctly.)

    Code changed in hudson
    User: kohsuke
    Path:
    /hudson/hudson/main/core/src/main/java/hudson/tasks/junit/SuiteResult.java (1.14)
    /hudson/hudson/main/core/src/main/java/hudson/tasks/junit/TestResult.java (1.18)
    /hudson/hudson/main/core/src/main/java/hudson/tasks/junit/CaseResult.java (1.15)
    /hudson/hudson/main/core/src/test/java/hudson/tasks/junit/SuiteResultTest.java (1.2)
    /hudson/hudson/main/core/src/test/resources/hudson/tasks/junit/junit-report-1472.xml (1.1)
    http://fisheye5.cenqua.com/changelog/hudson/?cs=MAIN:kohsuke:20080403080351

    Log:
    fixed issue #1472.
    For us to keep sanity in parsing JUnit XML, I think we have to break the earlier fix we made for JBoss guys. See http://www.nabble.com/difference-in-junit-publisher-and-ant-junitreport-td12265700.html#a12265700 for more about that.
    The problem is that the fix for issue #1233 is at odds with this XML that JBoss uses, when it comes to whether /@​name should win or /@​classname wins.
    JUnit XML from JBoss was said to be written by a custom formatter, so I think we can be justified in breaking that in favor of #1233 (although junit XSLT apparently handles that correctly.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions