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

Jenkins NUnit Plugin 0.14 incorrectly converts Unit XML results to JUnit

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Duplicate
    • Component/s: nunit-plugin
    • Labels:
      None
    • Environment:
      Windows Server 2003, Jenkins 1.497, Jenkins NUnit plugin 0.14, NUnit 2.6.2
    • Similar Issues:

      Description

      In the conversion of the NUnit XML results to JUnit, some tests are named incorrectly. When an NUnit output file contains a test-suite of type "TestFixture" containing a results element containing both test-suites of type "ParameterizedTest" and test-cases (not parameterized), the test-cases are reported with incorrect namespace and class names. It is as if some code were determining the namespace/class names to report by walking a certain number of tokens back in a fully qualified class name, and too many steps back are being taken for simple tests when parameterized tests are present.

      In TestResultLevel1.jpg all tests should appear under pacakge ASI.SOP.AmazonBTI.Tests. TestResultLevel3.jpg shows the badly parsed name AmazonUpcParseStrategyTests.ShouldRequireProductProgramFinder.

        Attachments

        1. ASI.SOP.AmazonBTI.Tests.xml
          19 kB
        2. JUnit-parameterized-simple.xml
          0.6 kB
        3. junitResult.xml
          22 kB
        4. NUnit-parameterized-simple.xml
          3 kB
        5. TestResultLevel1.jpg
          TestResultLevel1.jpg
          140 kB
        6. TestResultLevel2.jpg
          TestResultLevel2.jpg
          153 kB
        7. TestResultLevel3.jpg
          TestResultLevel3.jpg
          142 kB

          Issue Links

            Activity

            Hide
            blairconrad Blair Conrad added a comment -

            I think I'm seeing the same thing, on Windows7 and Windows Server 2008 R2, building the plugin from the GitHub source commit f73f7bdb0df8fa239c376dedfadab2d601fde68d.

            The problem as I see it is that when we're calculating $firstTestName in nunit-to-junit.xsl, after the first test-case in a results is found, we jump back up two levels to the test-suite, but then base the firstTestName off the first test-case descendent, on any level. This may not be the same test-case that we started from. And when we have parameterized tests, the names may be different enough to throw things off.

            I'll attach two very small NUnit source/JUnit output files that show the difference in just a second.

            In my example, we have a parameterized test that appears in the NUnit output before the simple test. When we try to find the firstTestName for the simple test, we accidentally use the name of the first parameterized test-case.

            I think the fix is to replace

            <xsl:variable name="firstTestName"
              select="results//test-case[1]//@name" />
            

            on lines 11 and 12 with

            <xsl:variable name="firstTestName"
              select="results/test-case[1]/@name" />
            

            Then we'll end up at the same test-case node we started at, and will get the correct firstTestName.

            I can also submit a pull request on GitHub, if you'd like.

            Show
            blairconrad Blair Conrad added a comment - I think I'm seeing the same thing, on Windows7 and Windows Server 2008 R2, building the plugin from the GitHub source commit f73f7bdb0df8fa239c376dedfadab2d601fde68d . The problem as I see it is that when we're calculating $firstTestName in nunit-to-junit.xsl , after the first test-case in a results is found, we jump back up two levels to the test-suite, but then base the firstTestName off the first test-case descendent, on any level. This may not be the same test-case that we started from. And when we have parameterized tests, the names may be different enough to throw things off. I'll attach two very small NUnit source/JUnit output files that show the difference in just a second. In my example, we have a parameterized test that appears in the NUnit output before the simple test. When we try to find the firstTestName for the simple test, we accidentally use the name of the first parameterized test-case. I think the fix is to replace <xsl:variable name= "firstTestName" select= "results //test- case [1]//@name" /> on lines 11 and 12 with <xsl:variable name= "firstTestName" select= "results/test- case [1]/@name" /> Then we'll end up at the same test-case node we started at, and will get the correct firstTestName. I can also submit a pull request on GitHub, if you'd like.
            Hide
            blairconrad Blair Conrad added a comment -

            Oh, drat. My comment was already made as a separate issue: JENKINS-13471. My pull request offer stands, though.

            Show
            blairconrad Blair Conrad added a comment - Oh, drat. My comment was already made as a separate issue: JENKINS-13471 . My pull request offer stands, though.

              People

              Assignee:
              slide_o_mix Alex Earl
              Reporter:
              dodren David Odren
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: