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

incorrect xsl transformation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • plugin-proposals
    • None
    • Platform: All, OS: All

      I have this Nunit formated file

      <test-results name='IEUnit Tests' total='6' failures='0' not-run='0'
      date='6/12/2007' time='2:46 PM'>
      <test-suite name='AdministrationPasswordTest' success='true' time='35.396'>
      <results>
      <test-case name='testChangePasswordFailEmptyForm' executed='true'
      success='true' time='5.065'></test-case>
      <test-case name='testChangePasswordFailOldPasswordKO' executed='true'
      success='true' time='5.066'></test-case>
      <test-case name='testChangePasswordFailNewPasswordTooShort' executed='true'
      success='true' time='5.049'></test-case>
      <test-case name='testChangePasswordFailNewPasswordNotRepeated' executed='true'
      success='true' time='5.05'></test-case>
      <test-case name='testChangePasswordFailNewPasswordKO' executed='true'
      success='true' time='5.066'></test-case>
      <test-case name='testChangePassword' executed='true' success='true'
      time='10.1'></test-case>
      </results>
      </test-suite>
      </test-results>

      it is found and processed by the plugin, but the output is nearly empty:
      <?xml version='1.0' encoding='UTF-8'?>
      <result>
      <suites>
      <suite>
      <name>AdministrationPasswordTest</name>
      <duration>0.0</duration>
      <cases/>
      </suite>
      </suites>
      <duration>0.0</duration>
      </result>

      FYI, here's the xsl I'm using with Bamboo to convert the file in a more JUnit
      format:
      <?xml version="1.0" encoding="utf-8"?>

      <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" indent="yes" encoding="utf-8" version="1.0"
      cdata-section-elements="failure" />

      <xsl:template match="test-results">
      <xsl:element name="testsuite">

      <xsl:attribute name="errors">0</xsl:attribute>

      <xsl:attribute name="skipped"><xsl:value-of select="@not-run"
      /></xsl:attribute>

      <xsl:attribute name="tests"><xsl:value-of select="@total" /></xsl:attribute>

      <xsl:attribute name="time"><xsl:value-of
      select="current()/test-suite/@time" /></xsl:attribute>

      <xsl:attribute name="failures"><xsl:value-of select="@failures"
      /></xsl:attribute>

      <xsl:attribute name="name"><xsl:value-of select="@name" /></xsl:attribute>

      <xsl:apply-templates select="current()/test-suite/results" mode="resultsMode" />

      </xsl:element>
      </xsl:template >

      <!-- DECLARING WHAT TO DO WHEN FINDING A "RESULTS" ELEMENT -->
      <xsl:template mode="resultsMode" match="results">
      <xsl:message>processing a result element</xsl:message>
      <xsl:apply-templates select="current()/test-case" mode="testCaseMode" />
      </xsl:template>

      <!-- DECLARING WHAT TO DO WHEN FINDING A "TEST-CASE" ELEMENT -->
      <xsl:template mode="testCaseMode" match="test-case">

      <xsl:element name="testcase">
      <xsl:attribute name="time"><xsl:value-of select="@time" /></xsl:attribute>

      <xsl:attribute name="name">in file <xsl:value-of
      select="current()/../../@name" />.js, <xsl:value-of select="@name"
      /></xsl:attribute>

      <xsl:apply-templates select="current()/failure" mode="failureMode" />
      </xsl:element>

      </xsl:template>

      <!-- DECLARING WHAT TO DO WHEN FINDING A "FAILURE" ELEMENT -->
      <xsl:template mode="failureMode" match="failure">

      <xsl:element name="failure">
      <xsl:attribute name="type">IEunit failure</xsl:attribute>

      <xsl:attribute name="message"><xsl:value-of select="current()/message/."
      /></xsl:attribute>
      </xsl:element>
      </xsl:template>

      </xsl:stylesheet>

      Hope this helps


      Vincent FUCHS

            Unassigned Unassigned
            vfuchs vfuchs
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: