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

Convert cunit XML to junit XML in xUnit plugin

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: xunit-plugin
    • Labels:
      None
    • Similar Issues:

      Description

      I am using xUnit plugin version 1.89

      I have a few tests that were written using cunit ( http://cunit.sourceforge.net )
      With cunit, it is possible to generate XML output in "automated mode".
      See:

      http://cunit.sourceforge.net/doc/running_tests.html#automated

      However, this XML format is not the same as JUnit XML, so can't be imported
      natively into Jenkins. I tried the cppunit converter in the xUnit plugin,
      but that didn't import the test results.

      I found this script which is part of the cyrus-imapd distribution:

      http://git.cyrusimap.org/cyrus-imapd/tree/cunit/cunit-to-junit.pl

      This script seems to do a good job of converting cunit xml to junit xml.

      Can we port the logic from this script to the xUnit plugin?

      It's not problem for me to use this script, but it would be super handy
      if this conversion logic was built into the xUnit plugin directly.

      I am new to writing Jenkins plugins, so would need some pointers. Thanks!

        Attachments

          Activity

          Hide
          gbois Gregory Boissinot added a comment -

          Thanks for the pointer.
          The first approch will be to include the Perl script into the xUnit plugin.
          Does anyone know how to call a Perl script from Java?

          Show
          gbois Gregory Boissinot added a comment - Thanks for the pointer. The first approch will be to include the Perl script into the xUnit plugin. Does anyone know how to call a Perl script from Java?
          Hide
          danielbeck Daniel Beck added a comment -

          You want to make perl a dependency of the xUnit plugin?

          Show
          danielbeck Daniel Beck added a comment - You want to make perl a dependency of the xUnit plugin?
          Hide
          rodrigc Craig Rodrigues added a comment -

          In this enhancement proposal, I did not intend to make this plugin depend on Perl.

          I suggest that:

          (1) Look at the perl code. The cunit-to-junit.pl test is pretty small and simple.
          The perl code uses a perl module which reads XML DOM. It reads the cunit XML,
          and then writes out a new junit XML file.

          (2) Port the logic to Java, and incorporate it in the xUnit plugin.

          That would be the best approach. I don't have experience with writing XML parsing code
          in Java inside a Jenkins plugin. Someone more familiar with this could probably
          code something up in a few hours.

          Show
          rodrigc Craig Rodrigues added a comment - In this enhancement proposal, I did not intend to make this plugin depend on Perl. I suggest that: (1) Look at the perl code. The cunit-to-junit.pl test is pretty small and simple. The perl code uses a perl module which reads XML DOM. It reads the cunit XML, and then writes out a new junit XML file. (2) Port the logic to Java, and incorporate it in the xUnit plugin. That would be the best approach. I don't have experience with writing XML parsing code in Java inside a Jenkins plugin. Someone more familiar with this could probably code something up in a few hours.
          Hide
          geoffroyjabouley Geoffroy Jabouley added a comment -

          Hello

          there is an available xsl style sheet that do pretty much the job:
          https://bitbucket.org/mcdeck/cunit-to-junit/src/3cd904af25d1a8d5da490737a68395ac646f6b42/cunit-to-junit.xsl

          To use it, follow the guideline here: https://github.com/shawnliang/cunit-to-junit
          (Xunit report --> custom tool --> set CUnit file pattern and specify the custom stylesheet)

          Show
          geoffroyjabouley Geoffroy Jabouley added a comment - Hello there is an available xsl style sheet that do pretty much the job: https://bitbucket.org/mcdeck/cunit-to-junit/src/3cd904af25d1a8d5da490737a68395ac646f6b42/cunit-to-junit.xsl To use it, follow the guideline here: https://github.com/shawnliang/cunit-to-junit (Xunit report --> custom tool --> set CUnit file pattern and specify the custom stylesheet)
          Hide
          xjom Mattias Vannergård added a comment -

          The xsl style sheet is not compilable using CUnit 2.1, Jenkins 1.596.2 and Java 8u31.

          See https://github.com/shawnliang/cunit-to-junit/issues/1

          Show
          xjom Mattias Vannergård added a comment - The xsl style sheet is not compilable using CUnit 2.1, Jenkins 1.596.2 and Java 8u31. See https://github.com/shawnliang/cunit-to-junit/issues/1
          Hide
          xjom Mattias Vannergård added a comment -

          Not an issue of the stylesheet. The download of the stylesheet failed. Case closed.

          Show
          xjom Mattias Vannergård added a comment - Not an issue of the stylesheet. The download of the stylesheet failed. Case closed.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: etiennebec
          Path:
          src/main/java/org/jenkinsci/plugins/xunit/types/CUnit.java
          src/main/java/org/jenkinsci/plugins/xunit/types/CUnitJunitHudsonTestType.java
          src/main/resources/org/jenkinsci/plugins/xunit/types/cunit-2.1-2-to-junit.xsl
          http://jenkins-ci.org/commit/xunit-plugin/0655050831ad9a123e0d41f9d05fdec263f3acce
          Log:
          [FIXED JENKINS-24382] Add basic support for CUnit

          I included Oliver van Porten XSL available here: https://bitbucket.org/mcdeck/cunit-to-junit (MIT license)

          Change-Id: Idb23d13b9e656c0d6e7da6a7cf7af5ffdb8ef8e6

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: etiennebec Path: src/main/java/org/jenkinsci/plugins/xunit/types/CUnit.java src/main/java/org/jenkinsci/plugins/xunit/types/CUnitJunitHudsonTestType.java src/main/resources/org/jenkinsci/plugins/xunit/types/cunit-2.1-2-to-junit.xsl http://jenkins-ci.org/commit/xunit-plugin/0655050831ad9a123e0d41f9d05fdec263f3acce Log: [FIXED JENKINS-24382] Add basic support for CUnit I included Oliver van Porten XSL available here: https://bitbucket.org/mcdeck/cunit-to-junit (MIT license) Change-Id: Idb23d13b9e656c0d6e7da6a7cf7af5ffdb8ef8e6
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Gregory Boissinot
          Path:
          src/main/java/org/jenkinsci/plugins/xunit/types/CUnit.java
          src/main/java/org/jenkinsci/plugins/xunit/types/CUnitJunitHudsonTestType.java
          src/main/resources/org/jenkinsci/plugins/xunit/types/cunit-2.1-to-junit.xsl
          src/test/java/org/jenkinsci/plugins/xunit/types/CUnitTest.java
          src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase1/junit-result.xml
          src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase1/testresult.xml
          src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase2/junit-result.xml
          src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase2/testresult.xml
          src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase3/junit-result.xml
          src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase3/testresult.xml
          src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase4/junit-result.xml
          src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase4/testresult.xml
          src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase5/junit-result.xml
          src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase5/testresult.xml
          http://jenkins-ci.org/commit/xunit-plugin/1dca7a06869f07dfa2b871ce3ae4dc29c8916b35
          Log:
          Merge pull request #38 from etiennebec/master

          [FIXED JENKINS-24382] Add basic support for CUnit

          Compare: https://github.com/jenkinsci/xunit-plugin/compare/237775a6cd64...1dca7a06869f

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Gregory Boissinot Path: src/main/java/org/jenkinsci/plugins/xunit/types/CUnit.java src/main/java/org/jenkinsci/plugins/xunit/types/CUnitJunitHudsonTestType.java src/main/resources/org/jenkinsci/plugins/xunit/types/cunit-2.1-to-junit.xsl src/test/java/org/jenkinsci/plugins/xunit/types/CUnitTest.java src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase1/junit-result.xml src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase1/testresult.xml src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase2/junit-result.xml src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase2/testresult.xml src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase3/junit-result.xml src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase3/testresult.xml src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase4/junit-result.xml src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase4/testresult.xml src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase5/junit-result.xml src/test/resources/org/jenkinsci/plugins/xunit/types/cunit/testcase5/testresult.xml http://jenkins-ci.org/commit/xunit-plugin/1dca7a06869f07dfa2b871ce3ae4dc29c8916b35 Log: Merge pull request #38 from etiennebec/master [FIXED JENKINS-24382] Add basic support for CUnit Compare: https://github.com/jenkinsci/xunit-plugin/compare/237775a6cd64...1dca7a06869f

            People

            • Assignee:
              gbois Gregory Boissinot
              Reporter:
              rodrigc Craig Rodrigues
            • Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: