Merge pull request #2 from tenwit/UpdateDocsWithNunitTransformParameter
Add docs for result option. Rename file.
This commit is contained in:
Коммит
2a7c741983
|
@ -4,7 +4,11 @@ Converts NUnit3 results to JUnit-style results. It deliberately drops some infor
|
|||
|
||||
The Jenkins NUnit publisher ("NUnit plugin" for Jenkins) requires NUnit2-style results and isn't keeping up with the snazziness of the JUnit plugin. Of particular interest to me, the JUnit plugin allows for claiming of individual test failures. XML files produced by transforming NUnit3 results with the attached XLST file are suitable for publishing via the JUnit plugin.
|
||||
|
||||
This transformation is XSLT 1.0 compliant. It would be simpler if it used XSL 2.0; for example, the for-each loop in the test-suite template could be reduced to a simple string-join. However since Jenkins doesn't (yet) have an XSLT plugin, I find that the easier way to use this transform in Jenkins is via Powershell, which currently (February 2016) supports only XSLT 1.0.
|
||||
The transform is usually used via nunit-console's --result option:
|
||||
|
||||
nunit3-console.exe YourTestAssembly.dll --result=junit-results.xml;transform=nunit3-junit.xslt
|
||||
|
||||
This transform is XSLT 1.0 compliant. It would be simpler if it used XSL 2.0; for example, the for-each loop in the test-suite template could be reduced to a simple string-join. XSLT 1.0 was chosen so that it can be used with Powershell, which currently (February 2016) supports only XSLT 1.0.
|
||||
|
||||
If you would like to run this using Powershell, here is a minimal Powershell script which you can run from Jenkins via the Powershell plugin. It uses the default NUnit output file name TestResults.xml and transforms it to a new file junit-results.xml, which you can then publish to Jenkins using the JUnit plugin.
|
||||
|
||||
|
|
|
@ -1,66 +1,66 @@
|
|||
<?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"/>
|
||||
|
||||
<xsl:template match="/test-run">
|
||||
<testsuites tests="{@testcasecount}" failures="{@failed}" disabled="{@skipped}" time="{@duration}">
|
||||
<xsl:apply-templates/>
|
||||
</testsuites>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="test-suite">
|
||||
<xsl:if test="test-case">
|
||||
<testsuite tests="{@testcasecount}" time="{@duration}" errors="{@testcasecount - @passed - @skipped - @failed}" failures="{@failed}" skipped="{@skipped}" timestamp="{@start-time}">
|
||||
<xsl:attribute name="name">
|
||||
<xsl:for-each select="ancestor-or-self::test-suite/@name">
|
||||
<xsl:value-of select="concat(., '.')"/>
|
||||
</xsl:for-each>
|
||||
</xsl:attribute>
|
||||
<xsl:apply-templates select="test-case"/>
|
||||
</testsuite>
|
||||
<xsl:apply-templates select="test-suite"/>
|
||||
</xsl:if>
|
||||
<xsl:if test="not(test-case)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="test-case">
|
||||
<testcase name="{@name}" assertions="{@asserts}" time="{@duration}" status="{@result}" classname="{@classname}">
|
||||
<xsl:if test="@runstate = 'Skipped' or @runstate = 'Ignored'">
|
||||
<skipped/>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:apply-templates/>
|
||||
</testcase>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="command-line"/>
|
||||
<xsl:template match="settings"/>
|
||||
|
||||
<xsl:template match="output">
|
||||
<system-out>
|
||||
<xsl:value-of select="output"/>
|
||||
</system-out>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="stack-trace">
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="test-case/failure">
|
||||
<failure message="{./message}">
|
||||
<xsl:value-of select="./stack-trace"/>
|
||||
</failure>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="test-suite/failure"/>
|
||||
|
||||
<xsl:template match="test-case/reason">
|
||||
<skipped message="{./message}"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="test-suite/reason"/>
|
||||
|
||||
<xsl:template match="properties"/>
|
||||
</xsl:stylesheet>
|
||||
|
||||
<?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"/>
|
||||
|
||||
<xsl:template match="/test-run">
|
||||
<testsuites tests="{@testcasecount}" failures="{@failed}" disabled="{@skipped}" time="{@duration}">
|
||||
<xsl:apply-templates/>
|
||||
</testsuites>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="test-suite">
|
||||
<xsl:if test="test-case">
|
||||
<testsuite tests="{@testcasecount}" time="{@duration}" errors="{@testcasecount - @passed - @skipped - @failed}" failures="{@failed}" skipped="{@skipped}" timestamp="{@start-time}">
|
||||
<xsl:attribute name="name">
|
||||
<xsl:for-each select="ancestor-or-self::test-suite/@name">
|
||||
<xsl:value-of select="concat(., '.')"/>
|
||||
</xsl:for-each>
|
||||
</xsl:attribute>
|
||||
<xsl:apply-templates select="test-case"/>
|
||||
</testsuite>
|
||||
<xsl:apply-templates select="test-suite"/>
|
||||
</xsl:if>
|
||||
<xsl:if test="not(test-case)">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="test-case">
|
||||
<testcase name="{@name}" assertions="{@asserts}" time="{@duration}" status="{@result}" classname="{@classname}">
|
||||
<xsl:if test="@runstate = 'Skipped' or @runstate = 'Ignored'">
|
||||
<skipped/>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:apply-templates/>
|
||||
</testcase>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="command-line"/>
|
||||
<xsl:template match="settings"/>
|
||||
|
||||
<xsl:template match="output">
|
||||
<system-out>
|
||||
<xsl:value-of select="output"/>
|
||||
</system-out>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="stack-trace">
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="test-case/failure">
|
||||
<failure message="{./message}">
|
||||
<xsl:value-of select="./stack-trace"/>
|
||||
</failure>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="test-suite/failure"/>
|
||||
|
||||
<xsl:template match="test-case/reason">
|
||||
<skipped message="{./message}"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="test-suite/reason"/>
|
||||
|
||||
<xsl:template match="properties"/>
|
||||
</xsl:stylesheet>
|
||||
|
Загрузка…
Ссылка в новой задаче