Part 1 of MAVEN-235.

Thanks to David Eric Pugh


git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@112817 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
dion
2003-02-03 13:30:42 +00:00
parent f7d8433452
commit b68a190810
2 changed files with 359 additions and 0 deletions

View File

@@ -0,0 +1,271 @@
<?xml version="1.0"?>
<jsl:stylesheet
select="$doc"
xmlns:j="jelly:core"
xmlns:jsl="jelly:jsl"
xmlns:x="jelly:xml"
xmlns:define="jelly:define"
xmlns:util="jelly:util"
xmlns:junit="junit"
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.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.DVSLFormatter"/>
<j:useBean var="fileutil" class="org.apache.velocity.texen.util.FileUtil"/>
<j:useBean var="pathtool" class="org.apache.maven.DVSLPathTool"/>
<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>]
</p>
</define:tag>
<define:tag name="testSuiteHeader">
<tr>
<th>Name</th>
<th>Tests</th>
<th>Errors</th>
<th>Failures</th>
<th>Time(s)</th>
</tr>
</define:tag>
<define:tag name="testCaseHeader">
<tr>
<th>Name</th>
<th>Status</th>
<th>Type</th>
<th>Time(s)</th>
</tr>
</define:tag>
<define:tag name="displayFailure">
<j:choose>
<j:when test="${current.attribute('message') != null}">
${htmlescape.getText(current.attribute('message').value)}
</j:when>
<j:otherwise>
N/A
</j:otherwise>
<p/>
<code>
${htmlescape.getText(current.value())}
</code>
</j:choose>
</define:tag>
</define:taglib>
<jsl:template match="testsuites">
<document>
<properties>
<title>JUnit Test Results</title>
</properties>
<body>
<section name="Summary">
<junit:nav/>
<j:set var="testCount"><x:expr select="sum(testsuite/@tests)"/></j:set>
<j:set var="errorCount"><x:expr select="sum(testsuite/@errors)"/></j:set>
<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>
<tr>
<th>Tests</th>
<th>Errors</th>
<th>Failures</th>
<th>Success rate</th>
<th>Time(s)</th>
</tr>
<tr>
<td>
<doc:formatAsNumber string="${testCount}" pattern="0"/>
</td>
<td>
<doc:formatAsNumber string="${errorCount}" pattern="0"/>
</td>
<td>
<doc:formatAsNumber string="${failureCount}" pattern="0"/>
</td>
<td>
<doc:formatAsNumber string="${successRate}" pattern="0.00%"/>
</td>
<td>
<doc:formatAsNumber string="${timeCount}" pattern="0.00"/>
</td>
</tr>
</table>
<p>
Note:
<i>failures</i> are anticipated and checked for with
assertions while
<i>errors</i> are unanticipated.
</p>
</section>
<section name="Package List">
<junit:nav/>
<table>
<!--
<junit:testSuiteHeader/>
-->
<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}"/>
<x:set var="quotedPackage" select='"${package}"'/>
<j:set var="testCount"><x:expr select="sum(./testsuite[./@package = $quotedPackage]/@tests)"/></j:set>
<j:set var="errorCount"><x:expr select="sum(./testsuite[./@package = $quotedPackage]/@errors)"/></j:set>
<j:set var="failureCount"><x:expr select="sum(./testsuite[./@package = $quotedPackage]/@failures)"/></j:set>
<j:set var="timeCount"><x:expr select="sum(./testsuite[./@package = $quotedPackage]/@time)"/></j:set>
<tr>
<td>
<a href="#${package}">${package}</a>
</td>
<td>
<doc:formatAsNumber string="${testCount}" pattern="0"/>
</td>
<td>
<doc:formatAsNumber string="${failureCount}" pattern="0"/>
</td>
<td>
<doc:formatAsNumber string="${errorCount}" pattern="0"/>
</td>
<td>
<doc:formatAsNumber string="${timeCount}" pattern="0.00"/>
</td>
</tr>
</j:forEach>
</table>
<p>
Note: package statistics are not computed recursively, they only
sum up all of its testsuites numbers.
</p>
<j:forEach var="testsuite" items="${testsuites}">
<j:set var="package" value="${testsuite.attribute('package').value}"/>
<x:set var="quotedPackage" select='"${package}"'/>
<a name="${package}"></a>
<subsection name="${package}">
<table>
<!--
<junit:testSuiteHeader/>
-->
<x:forEach var="test" select="/testsuites/testsuite[./@package = $quotedPackage]">
<tr>
<td>
<a href="#${test.attribute('name').value}">${test.attribute('name').value}</a>
</td>
<td>
<doc:formatAsNumber string="${test.attribute('tests').value}" pattern="0"/>
</td>
<td>
<doc:formatAsNumber string="${test.attribute('errors').value}" pattern="0"/>
</td>
<td>
<doc:formatAsNumber string="${test.attribute('failures').value}" pattern="0"/>
</td>
<td>
<doc:formatAsNumber string="${test.attribute('time').value}" pattern="0.000"/>
</td>
</tr>
</x:forEach>
</table>
</subsection>
</j:forEach>
</section>
<section name="Test Cases">
<junit:nav/>
<x:set var="testsuites" select="./testsuite"/>
<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
##
<x:set var="errors" select="$testsuite/error"/>
<j:forEach var="error" items="${errors}">
<tr>
<td colspan="4">
<junit:displayFailure current="${error}"/>
</td>
</tr>
</j:forEach>
<x:set var="testcases" select="$testsuite/testcase"/>
<j:forEach var="testcase" items="${testcases}">
<j:set var="failure" value="${testcase.selectSingleNode('failure')}"/>
<j:set var="error" value="${testcase.selectSingleNode('error')}"/>
<tr>
<td>${testcase.attribute("name").value}</td>
<j:choose>
<j:when test="${failure != null}">
<td style="width: 60px; color: red; font-weight: bold">Failure</td>
</j:when>
<j:when test="${error != null}">
<td style="width: 60px; color: red; font-weight: bold">Error</td>
</j:when>
<j:otherwise>
<td style="width: 60px;">Success</td>
</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>
</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">
<junit:displayFailure current="${failure}"/>
</td>
</tr>
</j:when>
<j:when test="${error != null}">
<tr>
<td colspan="3" style="padding-left: 50px">
<junit:displayFailure current="${error}"/>
</td>
</tr>
</j:when>
</j:choose>
</j:forEach>
</table>
</subsection>
</j:forEach>
</section>
</body>
</document>
</jsl:template>
</jsl:stylesheet>

View File

@@ -0,0 +1,88 @@
package org.apache.maven.cactus.sample;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
import junit.framework.TestCase;
/**
* Maven wants at least one JUnit test otherwise no documentation shows up in the site generated docs.
*
* @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
*
* @version $Id: DummyTest.java,v 1.1 2003/02/03 13:30:41 dion Exp $
*/
public class DummyTest extends TestCase {
public DummyTest(String name) {
super(name);
}
public void setUp() throws Exception {
}
public void testForceDocsToBeGenerated() throws Exception{
assertTrue(true);
}
public void tearDown() {
}
}