Apply MPJUNITREPORT-3

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114644 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
dion 2004-01-30 04:57:40 +00:00
parent 300da18259
commit 69f76de01e
3 changed files with 137 additions and 56 deletions

View File

@ -5,7 +5,7 @@
<pomVersion>3</pomVersion>
<id>maven-junit-report-plugin</id>
<name>Maven JUnit Report Plug-in</name>
<currentVersion>1.4</currentVersion>
<currentVersion>1.5-SNAPSHOT</currentVersion>
<description/>
<shortDescription>Reports from JUnit tests</shortDescription>
<url>http://maven.apache.org/reference/plugins/junit-report/</url>

View File

@ -11,24 +11,14 @@
xmlns:doc="doc"
trim="false">
<!-- This needs to be instantiated here to be available in the template matches -->
<j:useBean var="mavenTool" class="org.apache.maven.util.MavenTool"/>
<j:useBean var="numbers" class="java.text.DecimalFormat"/>
<j:useBean var="htmlescape" class="org.apache.velocity.anakia.Escape"/>
<j:useBean var="formatter" class="org.apache.maven.util.DVSLFormatter"/>
<j:useBean var="fileutil" class="org.apache.velocity.texen.util.FileUtil"/>
<j:useBean var="pathtool" class="org.apache.maven.util.DVSLPathTool"/>
<j:useBean var="stringTool" class="org.apache.maven.util.StringTool"/>
<define:taglib uri="junit">
<define:tag name="nav">
<p>
[
<a href="#Summary">summary</a>]
[
<a href="#Package List">package list</a>]
[
<a href="#Test Cases">test cases</a>]
[<a href="#Summary">summary</a>]
[<a href="#Package List">package list</a>]
[<a href="#Test Cases">test cases</a>]
</p>
</define:tag>
@ -55,7 +45,7 @@
<j:choose>
<j:when test="${current.attribute('message') != null}">
<code>
${htmlescape.getText(current.attribute('message').value)}
${current.attributeValue('message')}
</code>
</j:when>
<j:otherwise>
@ -63,6 +53,22 @@
</j:otherwise>
</j:choose>
</define:tag>
<!-- defined here to easily change images globally or set up relative paths -->
<define:tag name="displayImage">
<j:choose>
<j:when test="${kind == 'failure'}">
<img src="images/icon_warning_sml.gif" width="15" height="15" alt="Failure" />
</j:when>
<j:when test="${kind == 'error'}">
<img src="images/icon_error_sml.gif" width="15" height="15" alt="Error" />
</j:when>
<j:when test="${kind == 'success'}">
<img src="images/icon_success_sml.gif" width="15" height="15" alt="Success" />
</j:when>
</j:choose>
</define:tag>
</define:taglib>
<jsl:template match="testsuites">
@ -80,7 +86,8 @@
<j:set var="failureCount"><x:expr select="sum(testsuite/@failures)"/></j:set>
<j:set var="timeCount"><x:expr select="sum(testsuite/@time)"/></j:set>
<j:set var="successRate"><x:expr select="($testCount - ($failureCount + $errorCount)) div $testCount"/></j:set>
<table>
<table summary="JUnit result summary">
<thead>
<tr>
<th>Tests</th>
<th>Errors</th>
@ -88,6 +95,7 @@
<th>Success rate</th>
<th>Time(s)</th>
</tr>
</thead>
<tr>
<td>
<doc:formatAsNumber string="${testCount}" pattern="0"/>
@ -116,10 +124,12 @@
<section name="Package List">
<junit:nav/>
<table>
<table summary="Package List">
<thead>
<tr>
<th>Package</th><th>Tests</th><th>Errors</th><th>Failures</th><th>Success Rate</th><th>Time</th>
</tr>
</thead>
<x:set var="testsuites" select="./testsuite[not(./@package = preceding-sibling::testsuite/@package)]"/>
<j:forEach var="testsuite" items="${testsuites}">
<j:set var="package" value="${testsuite.attribute('package').value}"/>
@ -162,16 +172,33 @@
<a name="${package}"></a>
<subsection name="${package}">
<table>
<table summary="Tests for ${package}">
<thead>
<tr>
<th>Class</th><th>Tests</th><th>Errors</th><th>Failures</th><th>Success Rate</th><th>Time</th>
<th colspan="2">Class</th><th>Tests</th><th>Errors</th><th>Failures</th><th>Success Rate</th><th>Time</th>
</tr>
</thead>
<x:forEach var="test" select="/testsuites/testsuite[./@package = $quotedPackage]">
<j:set var="testCount"><x:expr select="${test.attribute('tests').value}" /></j:set>
<j:set var="errorCount"><x:expr select="${test.attribute('errors').value}" /></j:set>
<j:set var="failureCount"><x:expr select="${test.attribute('failures').value}" /></j:set>
<j:set var="successRate"><x:expr select="($testCount - ($failureCount + $errorCount)) div $testCount"/></j:set>
<tr>
<td>
<j:choose>
<j:when test="${errorCount != 0}">
<junit:displayImage kind="error" />
</j:when>
<j:when test="${failureCount != 0}">
<junit:displayImage kind="failure" />
</j:when>
<j:otherwise>
<junit:displayImage kind="success" />
</j:otherwise>
</j:choose>
</td>
<td>
<a href="#${test.attribute('name').value}">${test.attribute('name').value}</a>
</td>
@ -204,14 +231,7 @@
<j:forEach var="testsuite" items="${testsuites}">
<a name="${testsuite.attribute('name').value}"></a>
<subsection name="${testsuite.attribute('name').value}">
<table>
<!--
<junit:testCaseHeader/>
-->
## test can even not be started at all (failure to load the class)
## so report the error directly
##
<table summary="Testsuite: ${testsuite.attribute('name').value}">
<x:set var="errors" select="$testsuite/error"/>
<j:forEach var="error" items="${errors}">
@ -228,41 +248,43 @@
<j:forEach var="testcase" items="${testcases}">
<j:set var="failure" value="${testcase.selectSingleNode('failure')}"/>
<j:set var="error" value="${testcase.selectSingleNode('error')}"/>
<j:set var="testname" value="${testcase.attribute('name').value}"/>
<tr>
<td>${testcase.attribute("name").value}</td>
<td style="width:20px">
<j:choose>
<j:when test="${failure != null}">
<td style="width: 60px; color: red; font-weight: bold">Failure</td>
<a href="#${testname}"><junit:displayImage kind="failure" /></a>
</j:when>
<j:when test="${error != null}">
<td style="width: 60px; color: red; font-weight: bold">Error</td>
<a href="#${testname}"><junit:displayImage kind="error" /></a>
</j:when>
<j:otherwise>
<td style="width: 60px;">Success</td>
<junit:displayImage kind="success" />
</j:otherwise>
</j:choose>
<j:choose>
<j:when test="${testcase.attribute('time') != null}">
<td width="60px">
<doc:formatAsNumber string="${testcase.attribute('time').value}" pattern="0.00"/>
</td>
<td style="width:98%">${testcase.attribute("name").value}</td>
<td style="width:60px">
<j:if test="${testcase.attribute('time') != null}">
<doc:formatAsNumber string="${testcase.attribute('time').value}" pattern="0.00"/>
</j:if>
</td>
</j:when>
<j:otherwise>
<td width="60px"></td>
</j:otherwise>
</j:choose>
</tr>
<j:choose>
<j:when test="${failure != null}">
<tr>
<td colspan="3" style="padding-left: 50px">
<td colspan="3" style="padding-left: 20px">
<junit:displayFailure current="${failure}"/>
</td>
</tr>
</j:when>
<j:when test="${error != null}">
<tr>
<td colspan="3" style="padding-left: 50px">
<td colspan="3" style="padding-left: 20px">
<junit:displayFailure current="${error}"/>
</td>
</tr>
@ -273,6 +295,59 @@
</subsection>
</j:forEach>
</section>
<x:set var="errorCheck" select="/testsuites/testsuite/testcase/*" />
<j:if test="${!empty(errorCheck)}">
<section name="Failure details">
<x:forEach var="testcase" select="/testsuites/testsuite/testcase" trim="false">
<j:set var="failure" value="${testcase.selectSingleNode('failure')}"/>
<j:set var="error" value="${testcase.selectSingleNode('error')}"/>
<j:if test="${empty(failure)}">
<j:set var="failure" value="${error}"/>
</j:if>
<j:if test="${!empty(failure)}">
<j:set var="testname" value="${testcase.attribute('name').value}"/>
<table summary="Failure details for ${testname}">
<thead>
<tr>
<td style="width:20px">
<j:choose>
<j:when test="${!empty(error)}">
<junit:displayImage kind="error" />
</j:when>
<j:otherwise>
<junit:displayImage kind="failure"/>
</j:otherwise>
</j:choose>
</td>
<td style="width:96%"><strong><a name="${testname}">${testname}</a></strong></td>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2"><junit:displayFailure current="${failure}"/></td>
</tr>
<tr>
<td colspan="2">
<!-- removing stacktrace generated by maven -->
<!-- no way to preserve newlines, jelly strips out everything -->
<code>
${stringTool.splitStringAtLastDelim(stringTool.splitStringAtLastDelim(failure.text, 'at org.apache.commons.jelly.tags.ant.AntTag.doTag').get(0),
'at sun.reflect.NativeMethodAccessorImpl.invoke0(').get(0)}
</code>
</td>
</tr>
</tbody>
</table>
</j:if>
</x:forEach>
</section>
</j:if>
</body>
</document>
</jsl:template>

View File

@ -8,6 +8,12 @@
<body>
<release version="1.5" date="in CVS">
<action dev="dion" type="update">
Apply MPJUNITREPORT-3
</action>
</release>
<release version="1.4" date="2004-01-29">
<action dev="vmassol" type="update">
Added new goal <code>junit-report:report</code> which is is the same