This repository has been archived by the owner on Jun 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnunit-to-junit.xsl
91 lines (83 loc) · 3.43 KB
/
nunit-to-junit.xsl
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/test-results">
<testsuites>
<xsl:for-each select="test-suite//results//test-case[1]">
<xsl:for-each select="../..">
<xsl:variable name="firstTestName"
select="results//test-case[1]//@name" />
<xsl:variable name="assembly">
<xsl:choose>
<xsl:when test="substring($firstTestName, string-length($firstTestName)) = ')'">
<xsl:value-of select="substring-before($firstTestName, concat('.', @name))"></xsl:value-of>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(substring-before($firstTestName, @name), @name)" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!--
<xsl:variable name="assembly"
select="concat(substring-before($firstTestName, @name), @name)" />
-->
<!-- <redirect:write file="{$outputpath}/TEST-{$assembly}.xml">-->
<testsuite name="{$assembly}"
tests="{count(*/test-case)}" time="{@time}"
failures="{count(*/test-case/failure)}" errors="0"
skipped="{count(*/test-case[@executed='False'])}">
<xsl:for-each select="*/test-case">
<xsl:variable name="testcaseName">
<xsl:choose>
<xsl:when test="contains(./@name, concat($assembly,'.'))">
<xsl:value-of select="substring-after(./@name, concat($assembly,'.'))"/><!-- We either instantiate a "15" -->
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="./@name"/><!-- ...or a "20" -->
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<testcase classname="{$assembly}"
name="{$testcaseName}">
<xsl:if test="@time!=''">
<xsl:attribute name="time"><xsl:value-of select="@time" /></xsl:attribute>
</xsl:if>
<xsl:variable name="generalfailure"
select="./failure" />
<xsl:if test="./failure">
<xsl:variable name="failstack"
select="count(./failure/stack-trace/*) + count(./failure/stack-trace/text())" />
<failure>
<xsl:choose>
<xsl:when test="$failstack > 0 or not($generalfailure)">
MESSAGE:
<xsl:value-of select="./failure/message" />
+++++++++++++++++++
STACK TRACE:
<xsl:value-of select="./failure/stack-trace" />
</xsl:when>
<xsl:otherwise>
MESSAGE:
<xsl:value-of select="$generalfailure/message" />
+++++++++++++++++++
STACK TRACE:
<xsl:value-of select="$generalfailure/stack-trace" />
</xsl:otherwise>
</xsl:choose>
</failure>
</xsl:if>
<xsl:if test="@executed='False'">
<skipped>
<xsl:attribute name="message"><xsl:value-of select="./reason/message"/></xsl:attribute>
</skipped>
</xsl:if>
</testcase>
</xsl:for-each>
</testsuite>
<!-- </redirect:write>-->
</xsl:for-each>
</xsl:for-each>
</testsuites>
</xsl:template>
</xsl:stylesheet>