-
-
Save Kyrodan/1183475 to your computer and use it in GitHub Desktop.
MSpec to JUnit transformation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<!-- | |
Converts the MSpec (http://github.com/machine/machine.specifications) xml | |
output to JUnit output format. | |
The aim of this transformation is to integrate MSpec tests to Hudson CI. | |
Hudson understands test results presented in JUnit format. | |
Limitations: MSpec xml output currently doesn't contain detailed information | |
concerning tests failures and tests durations. So for such information JUnit | |
report is filled with fake data. | |
--> | |
<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}" time="{./@time div 1000.0}"> | |
<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
Added time info to JUnit output - needs current MSpec (as of 31.08.2011)
Initial Blog post: http://korneliuk.blogspot.com/2010/09/hot-to-integrate-mspec-into-hudson-ci.html