cunit-to-junit.xsl 1.53 KB
Newer Older
Ghislain MARY's avatar
Ghislain MARY committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
   <testsuites>
      <xsl:for-each select="//CUNIT_RUN_SUITE_SUCCESS">
          <xsl:variable name="suiteName" select="normalize-space(SUITE_NAME/text())"/>
	      <xsl:variable name="numberOfTests" select="count(CUNIT_RUN_TEST_RECORD/CUNIT_RUN_TEST_SUCCESS)"/>
	      <xsl:variable name="numberOfFailures" select="count(CUNIT_RUN_TEST_RECORD/CUNIT_RUN_TEST_FAILURE)"/>
      <testsuite
      	name="{$suiteName}"
      	tests="{$numberOfTests}"
		time="0"
		failures="{$numberOfFailures}"
		errors="0"
		skipped="0">
		
			<xsl:for-each select="CUNIT_RUN_TEST_RECORD/CUNIT_RUN_TEST_SUCCESS">
				<xsl:variable name="testname" select="normalize-space(TEST_NAME/text())"></xsl:variable>
				<testcase classname="{$suiteName}" name="{$testname}" time="0.0">
				</testcase>
			</xsl:for-each>
			
			<xsl:for-each select="CUNIT_RUN_TEST_RECORD/CUNIT_RUN_TEST_FAILURE">
				<xsl:variable name="testname" select="normalize-space(TEST_NAME/text())"></xsl:variable>
				<testcase classname="{$suiteName}" name="{$testname}" time="0.0">
					<failure>
Test failed at line <xsl:value-of select="LINE_NUMBER"></xsl:value-of> in file <xsl:value-of select="FILE_NAME"></xsl:value-of>: <xsl:value-of select="CONDITION"></xsl:value-of>
					</failure>
				</testcase>
			</xsl:for-each>
		
		
      </testsuite>

      </xsl:for-each>
   </testsuites>
</xsl:template>
</xsl:stylesheet>