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

Nunit plugin in raises exception if there are no tests in nunit xml

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Major
    • Resolution: Fixed
    • nunit-plugin
    • None
    • nunit 0.17, jenkins 1.651.1

    Description

      I recently upgraded jenkins and all our plugins and some of our builds are failing.

      After investigation it turns out that we produce some nunit test xml files that have no test results in (we might have set a test to [Ignore] temporarily for example).

      These used to work, and now do not.

      Example xml:

      <?xml version="1.0" encoding="UTF-8"?><testsuite errors="0" failures="0" name="RES.Coordinate.Calculation.Test.TurkeyTest" skipped="1" tests="1" time="">
      <testcase classname="RES.Coordinate.Calculation.Test.TurkeyTest" name="ED1950_to_WGS84("T1",556351,4611739,27.67626007d,41.65371627d)">
      <skipped message=""/>
      </testcase>
      </testsuite>

      The output is as follows:

      Recording NUnit tests results
      ERROR: Step ‘Publish NUnit test result report’ aborted due to exception:
      java.io.IOException: Failed to read D:\EX00_WS\temporary-junit-reports\TEST-RES.Coordinate.Calculation.Test.TurkeyTest_2.xml
      at hudson.tasks.junit.TestResult.parse(TestResult.java:306)
      at hudson.tasks.junit.TestResult.parsePossiblyEmpty(TestResult.java:244)
      at hudson.tasks.junit.TestResult.parse(TestResult.java:175)
      at hudson.tasks.junit.TestResult.parse(TestResult.java:154)
      at hudson.tasks.junit.TestResult.<init>(TestResult.java:126)
      at hudson.plugins.nunit.NUnitPublisher$1.invoke(NUnitPublisher.java:202)
      at hudson.plugins.nunit.NUnitPublisher$1.invoke(NUnitPublisher.java:191)
      at hudson.FilePath.act(FilePath.java:990)
      at hudson.FilePath.act(FilePath.java:968)
      at hudson.plugins.nunit.NUnitPublisher.getTestResult(NUnitPublisher.java:191)
      at hudson.plugins.nunit.NUnitPublisher.recordTestResult(NUnitPublisher.java:147)
      at hudson.plugins.nunit.NUnitPublisher.perform(NUnitPublisher.java:109)
      at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
      at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
      at hudson.model.Build$BuildExecution.post2(Build.java:185)
      at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
      at hudson.model.Run.execute(Run.java:1763)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:98)
      at hudson.model.Executor.run(Executor.java:410)
      Caused by: java.lang.NumberFormatException: empty String
      at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
      at sun.misc.FloatingDecimal.parseFloat(Unknown Source)
      at java.lang.Float.parseFloat(Unknown Source)
      at hudson.tasks.junit.SuiteResult.<init>(SuiteResult.java:170)
      at hudson.tasks.junit.SuiteResult.parseSuite(SuiteResult.java:144)
      at hudson.tasks.junit.SuiteResult.parse(SuiteResult.java:129)
      at hudson.tasks.junit.TestResult.parse(TestResult.java:301)
      ... 20 more
      Build result "FAILURE". Skipping script.

      Cheers

      Cedd

      Attachments

        Activity

          cedd cedd burge created issue -

          I am also encountering this issue. It seems to happen when all the tests in a test fixture are marked as ignored for me as well.

          daflame Jeremy Wilkins added a comment - I am also encountering this issue. It seems to happen when all the tests in a test fixture are marked as ignored for me as well.

          I experience the same issue with any tests that are marked with ignore attribute.

          ERROR: Step ‘Publish NUnit test result report’ aborted due to exception:
          java.io.IOException: Failed to read T:\workspace\project\temporary-junit-reports\TEST-testcase.xml
          at hudson.tasks.junit.TestResult.parse(TestResult.java:306)
          at hudson.tasks.junit.TestResult.parsePossiblyEmpty(TestResult.java:244)
          at hudson.tasks.junit.TestResult.parse(TestResult.java:175)
          at hudson.tasks.junit.TestResult.parse(TestResult.java:154)
          at hudson.tasks.junit.TestResult.<init>(TestResult.java:126)
          at hudson.plugins.nunit.NUnitPublisher$1.invoke(NUnitPublisher.java:243)
          at hudson.plugins.nunit.NUnitPublisher$1.invoke(NUnitPublisher.java:226)
          at hudson.FilePath.act(FilePath.java:990)
          at hudson.FilePath.act(FilePath.java:968)
          at hudson.plugins.nunit.NUnitPublisher.getTestResult(NUnitPublisher.java:226)
          at hudson.plugins.nunit.NUnitPublisher.recordTestResult(NUnitPublisher.java:189)
          at hudson.plugins.nunit.NUnitPublisher.perform(NUnitPublisher.java:152)
          at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
          at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
          at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
          at hudson.model.Build$BuildExecution.post2(Build.java:185)
          at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
          at hudson.model.Run.execute(Run.java:1763)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          at hudson.model.ResourceController.execute(ResourceController.java:98)
          at hudson.model.Executor.run(Executor.java:410)
          Caused by: java.lang.NumberFormatException: empty String
          at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
          at java.lang.Float.parseFloat(Unknown Source)
          at hudson.tasks.junit.SuiteResult.<init>(SuiteResult.java:170)
          at hudson.tasks.junit.SuiteResult.parseSuite(SuiteResult.java:144)
          at hudson.tasks.junit.SuiteResult.parse(SuiteResult.java:129)
          at hudson.tasks.junit.TestResult.parse(TestResult.java:301)
          ... 20 more

          nikitaignatov Nikita Ignatov added a comment - I experience the same issue with any tests that are marked with ignore attribute. ERROR: Step ‘Publish NUnit test result report’ aborted due to exception: java.io.IOException: Failed to read T:\workspace\project\temporary-junit-reports\TEST-testcase.xml at hudson.tasks.junit.TestResult.parse(TestResult.java:306) at hudson.tasks.junit.TestResult.parsePossiblyEmpty(TestResult.java:244) at hudson.tasks.junit.TestResult.parse(TestResult.java:175) at hudson.tasks.junit.TestResult.parse(TestResult.java:154) at hudson.tasks.junit.TestResult.<init>(TestResult.java:126) at hudson.plugins.nunit.NUnitPublisher$1.invoke(NUnitPublisher.java:243) at hudson.plugins.nunit.NUnitPublisher$1.invoke(NUnitPublisher.java:226) at hudson.FilePath.act(FilePath.java:990) at hudson.FilePath.act(FilePath.java:968) at hudson.plugins.nunit.NUnitPublisher.getTestResult(NUnitPublisher.java:226) at hudson.plugins.nunit.NUnitPublisher.recordTestResult(NUnitPublisher.java:189) at hudson.plugins.nunit.NUnitPublisher.perform(NUnitPublisher.java:152) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723) at hudson.model.Build$BuildExecution.post2(Build.java:185) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668) at hudson.model.Run.execute(Run.java:1763) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:410) Caused by: java.lang.NumberFormatException: empty String at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source) at java.lang.Float.parseFloat(Unknown Source) at hudson.tasks.junit.SuiteResult.<init>(SuiteResult.java:170) at hudson.tasks.junit.SuiteResult.parseSuite(SuiteResult.java:144) at hudson.tasks.junit.SuiteResult.parse(SuiteResult.java:129) at hudson.tasks.junit.TestResult.parse(TestResult.java:301) ... 20 more
          rtyler R. Tyler Croy made changes -
          Field Original Value New Value
          Workflow JNJira [ 170569 ] JNJira + In-Review [ 183959 ]
          slide_o_mix Alex Earl added a comment -

          Can someone please upload an nunit xml file that causes this issue?

          slide_o_mix Alex Earl added a comment - Can someone please upload an nunit xml file that causes this issue?
          slide_o_mix Alex Earl made changes -
          Assignee Bruno P. Kinoshita [ kinow ] Alex Earl [ slide_o_mix ]
          slide_o_mix Alex Earl added a comment -

          After looking at this again, it looks like the XML is badly formed:

           

          <?xml version="1.0" encoding="UTF-8"?><testsuite errors="0" failures="0" name="RES.Coordinate.Calculation.Test.TurkeyTest" skipped="1" tests="1" time="">
          <testcase classname="RES.Coordinate.Calculation.Test.TurkeyTest" name="ED1950_to_WGS84("T1",556351,4611739,27.67626007d,41.65371627d)">
          <skipped message=""/>
          </testcase>
          </testsuite>

           

          If you look at the name attribute of the testcase, there are quotes inside quotes "T1", which is not allowed. They either need to be escaped as XML entities (") or single quotes need to be used.

          I need additional XML's from other folks to look into their issues,

          slide_o_mix Alex Earl added a comment - After looking at this again, it looks like the XML is badly formed:   <?xml version= "1.0" encoding= "UTF-8" ?><testsuite errors= "0" failures= "0" name= "RES.Coordinate.Calculation.Test.TurkeyTest" skipped= "1" tests= "1" time=""> <testcase classname= "RES.Coordinate.Calculation.Test.TurkeyTest" name= "ED1950_to_WGS84(" T1 ",556351,4611739,27.67626007d,41.65371627d)" > <skipped message=""/> </testcase> </testsuite>   If you look at the name attribute of the testcase, there are quotes inside quotes "T1", which is not allowed. They either need to be escaped as XML entities (") or single quotes need to be used. I need additional XML's from other folks to look into their issues,
          slide_o_mix Alex Earl added a comment -

          Also, please make sure that you don't set fail if no results. 

          slide_o_mix Alex Earl added a comment - Also, please make sure that you don't set fail if no results. 

          Code changed in jenkins
          User: Alex Earl
          Path:
          pom.xml
          src/main/java/hudson/plugins/nunit/NUnitArchiver.java
          src/main/java/hudson/plugins/nunit/NUnitPublisher.java
          src/main/java/hudson/plugins/nunit/NUnitReportTransformer.java
          src/main/resources/hudson/plugins/nunit/NUnitPublisher/config.jelly
          src/main/resources/index.jelly
          src/test/java/hudson/plugins/nunit/NUnitArchiverTest.java
          src/test/java/hudson/plugins/nunit/NUnitIntegrationTest.java
          src/test/java/hudson/plugins/nunit/NUnitPublisherTest.java
          src/test/java/hudson/plugins/nunit/NUnitReportTransformerTest.java
          src/test/java/hudson/plugins/nunit/NUnitToJUnitXslTest.java
          src/test/resources/hudson/plugins/nunit/NUnit-issue34452.xml
          http://jenkins-ci.org/commit/nunit-plugin/5bd699cedeae13475a3321637da3d5c47397b362
          Log:
          Fix JENKINS-27618, JENKINS-27906, JENKINS-34452, JENKINS-42967

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alex Earl Path: pom.xml src/main/java/hudson/plugins/nunit/NUnitArchiver.java src/main/java/hudson/plugins/nunit/NUnitPublisher.java src/main/java/hudson/plugins/nunit/NUnitReportTransformer.java src/main/resources/hudson/plugins/nunit/NUnitPublisher/config.jelly src/main/resources/index.jelly src/test/java/hudson/plugins/nunit/NUnitArchiverTest.java src/test/java/hudson/plugins/nunit/NUnitIntegrationTest.java src/test/java/hudson/plugins/nunit/NUnitPublisherTest.java src/test/java/hudson/plugins/nunit/NUnitReportTransformerTest.java src/test/java/hudson/plugins/nunit/NUnitToJUnitXslTest.java src/test/resources/hudson/plugins/nunit/NUnit-issue34452.xml http://jenkins-ci.org/commit/nunit-plugin/5bd699cedeae13475a3321637da3d5c47397b362 Log: Fix JENKINS-27618 , JENKINS-27906 , JENKINS-34452 , JENKINS-42967
          slide_o_mix Alex Earl added a comment -

          Will be fixed in 0.19

          slide_o_mix Alex Earl added a comment - Will be fixed in 0.19
          slide_o_mix Alex Earl made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]

          People

            slide_o_mix Alex Earl
            cedd cedd burge
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: