Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-1085

NumberFormatException when parsing junit report

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Critical Critical
    • junit-plugin
    • None
    • Platform: All, OS: All

      The JUnit task has issues reading the JUnit test report from one of my
      components.

      The exception is as follows:

      hudson.util.IOException2: Failed to
      read /data/hudson_builds/jobs/Site_Build/workspace/trunk/systemtest/dbsyncupdate
      /target/surefire-reports/TEST-au.com.east.st.DbsyncUpdateSystemTest.xml
      at hudson.tasks.junit.TestResult.parse(TestResult.java:125)
      at hudson.tasks.junit.TestResult.parse(TestResult.java:92)
      at hudson.tasks.junit.TestResult.<init>(TestResult.java:69)
      at hudson.tasks.junit.JUnitResultArchiver$1.invoke
      (JUnitResultArchiver.java:67)
      at hudson.tasks.junit.JUnitResultArchiver$1.invoke
      (JUnitResultArchiver.java:52)
      at hudson.FilePath.act(FilePath.java:291)
      at hudson.tasks.junit.JUnitResultArchiver.perform
      (JUnitResultArchiver.java:52)
      at hudson.model.Build$RunnerImpl.performAllBuildStep(Build.java:150)
      at hudson.model.Build$RunnerImpl.post2(Build.java:137)
      at hudson.model.AbstractBuild$AbstractRunner.post
      (AbstractBuild.java:254)
      at hudson.model.Run.run(Run.java:667)
      at hudson.model.Build.run(Build.java:102)
      at hudson.model.ResourceController.execute(ResourceController.java:70)
      at hudson.model.Executor.run(Executor.java:64)
      Caused by: java.lang.NumberFormatException: For input string: "2,297.255"
      at sun.misc.FloatingDecimal.readJavaFormatString
      (FloatingDecimal.java:1224)
      at java.lang.Float.parseFloat(Float.java:394)
      at hudson.tasks.junit.CaseResult.parseTime(CaseResult.java:36)
      at hudson.tasks.junit.CaseResult.<init>(CaseResult.java:31)
      at hudson.tasks.junit.SuiteResult.<init>(SuiteResult.java:65)
      at hudson.tasks.junit.TestResult.parse(TestResult.java:121)
      ... 13 more

      Inspecting the offending Junit report I can see the following:

      <testsuite errors="0" skipped="0" tests="6" time="3,000.262" failures="0"
      name="au.com.east.st.DbsyncUpdateSystemTest">

      and:
      <testcase time="2,297.255" name="testTCDS009"/>

      Looking at the code for the parseTime() method in CaseResult it is only using
      Float.parseFloat(). This doesn't support floats formatted with comma
      separators. The class should be using the DecimalFormat class to parse the
      number instead.

      The same can be said of the CaseResult(SuiteResult parent, Element testCase,
      String testCaseName) constructor.

            Unassigned Unassigned
            jchharris jchharris
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: