Skip to content

Instantly share code, notes, and snippets.

@MikeBild
Created June 18, 2011 18:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikeBild/1033374 to your computer and use it in GitHub Desktop.
Save MikeBild/1033374 to your computer and use it in GitHub Desktop.
MSpec to JUnit XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:variable name="specs" select="//specification"/>
<xsl:template match="MSpec">
<testsuite
name="Specifications"
tests="{count($specs)}"
errors="0"
failures="{count($specs[@status='failed'])}"
skipped="{count($specs[@status='not-implemented' or @status='ignored'])}">
<xsl:apply-templates select="//specification"/>
</testsuite>
</xsl:template>
<xsl:template match="specification">
<xsl:variable name="classname">
<xsl:value-of select="ancestor::assembly/@name"/>.<xsl:value-of select="ancestor::concern/@name"/>.<xsl:value-of select="ancestor::context/@name"/>
</xsl:variable>
<testcase classname="{$classname}" name="{./@name}">
<xsl:if test="@status = 'failed'">
<failure message="Specification failed">See html report for details</failure>
</xsl:if>
<xsl:if test="@status = 'not-implemented' or @status = 'ignored'">
<skipped message="Specification skipped">
</skipped>
</xsl:if>
</testcase>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment