kaz         02/03/09 07:55:46

  Modified:    src/java/org/apache/maven DVSLFormatter.java
               src/templates/build build-test.xml
               xdocs    project.xml
               xdocs/stylesheets jdepend.dvsl
  Added:       xdocs/stylesheets junit.dvsl
  Log:
  JUnit test results are now converted to an xdoc that can be rendered as
  part of a Maven generated site.  The following changes were made:
  
  - DVSLFormatter has been modified to allow generic formatting of numbers
    using patterns (just uses a DecimalFormatter).
  
  - junit.dvsl has been created (based entirely off of the Ant
    junit-noframes.xsl stylesheet).  This generates an xdoc that can later
    be transformed with site.dvsl.
  
  - Minor changes to jdepend.dvsl to utlize the new DVSLFormatter.
  
  - Build-test.xml has been modified to consolidate all of the JUnit
    reports using junitreport task, then a dvsl task transforms that
    output to an xdoc.
  
  - Link has been added to the Maven web page to show the results of the
    unit tests.
  
  Revision  Changes    Path
  1.2       +18 -9     
jakarta-turbine-maven/src/java/org/apache/maven/DVSLFormatter.java
  
  Index: DVSLFormatter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/DVSLFormatter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DVSLFormatter.java        1 Mar 2002 18:11:26 -0000       1.1
  +++ DVSLFormatter.java        9 Mar 2002 15:55:46 -0000       1.2
  @@ -54,7 +54,7 @@
    * <http://www.apache.org/>.
    */
   
  -import java.text.NumberFormat;
  +import java.text.DecimalFormat;
   
   /** 
    * Formatting tool for use with the DVSL toolbox.  This class contains
  @@ -62,24 +62,33 @@
    * shouldn't be done in a DVSL stylesheet.
    * 
    * @author <a href="mailto:[EMAIL PROTECTED]";>Pete Kazmier</a>
  - * @version $Id: DVSLFormatter.java,v 1.1 2002/03/01 18:11:26 kaz Exp $
  + * @version $Id: DVSLFormatter.java,v 1.2 2002/03/09 15:55:46 kaz Exp $
    */
   public class DVSLFormatter
   {
       /** 
  -     * Instance of a percentage number formatter.
  +     * Instance of a formatter.
        */
  -    private static NumberFormat percent = NumberFormat.getPercentInstance();
  +    private static DecimalFormat formatter = new DecimalFormat();
   
       /** 
  -     * Formats a decimal as a percentage using the current Locale.
  +     * Formats a string as a number using the specified pattern.
  +     * Patterns are specified using the same format as <code>
  +     * java.text.DecimalFormat</code>.
  +     * <p/>
  +     * This method is thead-hostile.
        * 
  -     * @param value A decimal representing a percentage.
  -     * @return The decimal formatted as a percentage.
  +     * @see java.text.DecimalFormat
  +     * @param value The number to format.
  +     * @param pattern The pattern used to format.
  +     * @return A string formatted using the specified pattern.
  +     * @throws IllegalArgumentException If an invalid pattern is
  +     * specified.
        */
  -    public static final String formatPercentage(Double value)
  +    public static final String formatNumber(Number value, String pattern)
       {
  -        return percent.format(value.doubleValue());
  +        formatter.applyPattern(pattern);
  +        return formatter.format(value.doubleValue());
       }
   }
   
  
  
  
  1.10      +30 -1     jakarta-turbine-maven/src/templates/build/build-test.xml
  
  Index: build-test.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/build-test.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- build-test.xml    8 Mar 2002 14:23:03 -0000       1.9
  +++ build-test.xml    9 Mar 2002 15:55:46 -0000       1.10
  @@ -53,6 +53,15 @@
       name="run-tests" 
       depends="compile">
       
  +    <taskdef 
  +      name="dvsl" 
  +      classname="org.apache.tools.dvsl.DVSLTask">
  +
  +      <classpath>
  +        <path refid="classpath"/>
  +      </classpath>
  +    </taskdef>
  +
       <echo>
         Running all JUnit tests
       </echo>
  @@ -62,7 +71,7 @@
       
       <junit printSummary="yes" failureProperty="test.failure">
         <sysproperty key="basedir" value="${basedir}"/>
  -      <formatter type="plain"/>
  +      <formatter type="xml"/>
         <classpath>
           <path refid="classpath"/>
           <pathelement location="${build.dest}"/>
  @@ -73,6 +82,26 @@
           </fileset>
         </batchtest>
       </junit>
  +
  +    <!-- Consolidate the reports into a single -->
  +    <junitreport todir="${test.reportsDirectory}">
  +      <fileset dir="${test.reportsDirectory}">
  +        <include name="TEST-*.xml"/>
  +      </fileset>
  +    </junitreport>
  +
  +    <!-- Convert single report into an xdoc -->
  +    <dvsl
  +      basedir="${basedir}"
  +      style="${docs.src}/stylesheets/junit.dvsl"
  +      toolboxfile="${docs.src}/toolbox.props"
  +      in="${test.reportsDirectory}/TESTS-TestSuites.xml"
  +      out="${gen.docs}/junit-report.xml">
  +      <classpath>
  +        <path refid="classpath"/>
  +        <path refid="maven-classpath"/>
  +      </classpath>
  +    </dvsl>
     </target>
   
     <!-- ================================================================== -->
  
  
  
  1.16      +1 -0      jakarta-turbine-maven/xdocs/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/xdocs/project.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- project.xml       2 Mar 2002 20:35:37 -0000       1.15
  +++ project.xml       9 Mar 2002 15:55:46 -0000       1.16
  @@ -29,6 +29,7 @@
         <item name="Source XReference"       href="/xref/index.html"/>
         <item name="Change Log"              href="/changelog.html"/>
         <item name="Metrics Results"         href="/jdepend-report.html"/>
  +      <item name="Unit Tests"              href="/junit-report.html"/>
       </menu>
     </body>
   </project>
  
  
  
  1.2       +200 -192  jakarta-turbine-maven/xdocs/stylesheets/jdepend.dvsl
  
  Index: jdepend.dvsl
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/xdocs/stylesheets/jdepend.dvsl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jdepend.dvsl      1 Mar 2002 18:11:26 -0000       1.1
  +++ jdepend.dvsl      9 Mar 2002 15:55:46 -0000       1.2
  @@ -1,23 +1,23 @@
   #######################################################################
   ## J D E P E N D    D V S L    S T Y L E S H E E T                   ##
   #######################################################################
  -##
  +
   ## This stylesheet is used to transform the output of JDepend's xml
   ## generator.  The XML is transformed into a standard xdoc that can
   ## then be transformed (yet again) using whatever stylesheet is used
   ## to format one's site.
   ##
  -## Version: $Id: jdepend.dvsl,v 1.1 2002/03/01 18:11:26 kaz Exp $
  +## Based on the XSL stylesheet jdepend.xsl from Ant.
  +##
  +## Version: $Id: jdepend.dvsl,v 1.2 2002/03/09 15:55:46 kaz Exp $
   
   #######################################################################
   ## V E L O C I T Y    M A C R O S                                    ##
   #######################################################################
   
  -## Prints a standard section header with the addition of some links
  -## that can be used for navigation in the document.
  +## Prints a standard navbar for navigation.
   ##
  -#macro (section $title)
  -    <section name="$title">
  +#macro (navbar)
         <p>
           [<a href="#Summary">summary</a>]
           [<a href="#Packages">packages</a>]
  @@ -56,11 +56,12 @@
       #end
   #end
   
  -## Convert a string that represents a decimal as a percentage.
  +## Convert a string that represents a number using the specified
  +## pattern.  
   ##
  -#macro (percent $string)
  -    #set ($double = $context.toolbox.numbers.createDouble($string))
  -    $context.toolbox.formatter.formatPercentage($double)
  +#macro (formatAsNumber $string $pattern)
  +    #set ($value = $context.toolbox.numbers.createNumber($string))
  +    $context.toolbox.formatter.formatNumber($value, $pattern)
   #end
   
   #######################################################################
  @@ -79,213 +80,220 @@
   
     <body>
       ###################################################################
  -    #section ("Metric Results")
  -    <p>
  -      The following document contains the results of a <a
  -      href="http://www.clarkware.com/software/JDepend.html";>JDepend</a>
  -      metric analysis.  The various metrics are defined at the bottom
  -      of this document.
  -    </p>
  +    <section name="Metric Results">
  +      #navbar ()
  +      <p>
  +        The following document contains the results of a <a
  +        href="http://www.clarkware.com/software/JDepend.html";>JDepend</a>
  +        metric analysis.  The various metrics are defined at the bottom
  +        of this document.
  +      </p>
       </section>
   
       ###################################################################
  -    #section ("Summary")     
  -    <table>
  -      <tr>
  -        <th>Package</th>
  -        <th><font size="-1">Total<br/>Classes</font></th>
  -        <th><font size="-1">Abstract<br/>Classes</font></th>
  -        <th><font size="-1">Concrete<br/>Classes</font></th>
  -        <th><font size="-1">Afferent<br/>Couplings</font></th>
  -        <th><font size="-1">Efferent<br/>Couplings</font></th>
  -        <th><font size="-1">Abstractness</font></th>
  -        <th><font size="-1">Instability</font></th>
  -        <th><font size="-1">Distance</font></th>
  -      </tr>
  -
  -    #foreach ($package in $node.selectNodes("./Packages/Package"))
  -        #if (! $package.get("error"))
  -      <tr>
  -        <td>
  -          <a href="#$package.attribute("name")">$package.attribute("name")</a>
  -        </td>
  -        <td align="right">$package.valueOf("Stats/TotalClasses")</td>
  -        <td>$package.valueOf("Stats/AbstractClasses")</td>
  -        <td>$package.valueOf("Stats/ConcreteClasses")</td>
  -        <td>$package.valueOf("Stats/Ca")</td>
  -        <td>$package.valueOf("Stats/Ce")</td>
  -        <td>#percent ($package.valueOf("Stats/A"))</td>
  -        <td>#percent ($package.valueOf("Stats/I"))</td>
  -        <td>#percent ($package.valueOf("Stats/D"))</td>
  -      </tr>
  -        #end
  -    #end
  +    <section name="Summary">
  +      #navbar ()
  +      <table>
  +        <tr>
  +          <th>Package</th>
  +          <th><font size="-1">Total<br/>Classes</font></th>
  +          <th><font size="-1">Abstract<br/>Classes</font></th>
  +          <th><font size="-1">Concrete<br/>Classes</font></th>
  +          <th><font size="-1">Afferent<br/>Couplings</font></th>
  +          <th><font size="-1">Efferent<br/>Couplings</font></th>
  +          <th><font size="-1">Abstractness</font></th>
  +          <th><font size="-1">Instability</font></th>
  +          <th><font size="-1">Distance</font></th>
  +        </tr>
   
  -    #foreach ($package in $node.selectNodes("./Packages/Package"))
  -        #if ($package.get("error"))
  -      <tr>
  -        <td colspan="1">$package.attribute("name")</td>
  -        <td colspan="8">$package.valueOf("error")</td>
  -      </tr>
  -        #end
  -    #end
  -    </table>
  +      #foreach ($package in $node.selectNodes("./Packages/Package"))
  +          #if (! $package.get("error"))
  +        <tr>
  +          <td>
  +            <a href="#$package.attribute("name")">$package.attribute("name")</a>
  +          </td>
  +          <td align="right">$package.valueOf("Stats/TotalClasses")</td>
  +          <td>$package.valueOf("Stats/AbstractClasses")</td>
  +          <td>$package.valueOf("Stats/ConcreteClasses")</td>
  +          <td>$package.valueOf("Stats/Ca")</td>
  +          <td>$package.valueOf("Stats/Ce")</td>
  +          <td>#formatAsNumber ($package.valueOf("Stats/A") "0%")</td>
  +          <td>#formatAsNumber ($package.valueOf("Stats/I") "0%")</td>
  +          <td>#formatAsNumber ($package.valueOf("Stats/D") "0%")</td>
  +        </tr>
  +          #end
  +      #end
  +
  +      #foreach ($package in $node.selectNodes("./Packages/Package"))
  +          #if ($package.get("error"))
  +        <tr>
  +          <td colspan="1">$package.attribute("name")</td>
  +          <td colspan="8">$package.valueOf("error")</td>
  +        </tr>
  +          #end
  +      #end
  +      </table>
       </section>
   
       ###################################################################
  -    #section ("Packages")
  +    <section name="Packages">
  +      #navbar ()
   
  -    #foreach ($package in $node.selectNodes("./Packages/Package"))
  -        #if (! $package.get("error"))
  -      <subsection name="${package.attribute('name')}">
  -        <table>
  -          <tr>
  -            <th>Afferent Couplings</th>
  -            <th>Efferent Couplings</th>
  -            <th>Abstractness</th>
  -            <th>Instability</th>
  -            <th>Distance</th>
  -          </tr>
  -          <tr>
  -            <td>$package.valueOf("Stats/Ca")</td>
  -            <td>$package.valueOf("Stats/Ce")</td>
  -            <td>#percent ($package.valueOf("Stats/A"))</td>
  -            <td>#percent ($package.valueOf("Stats/I"))</td>
  -            <td>#percent ($package.valueOf("Stats/D"))</td>
  -          </tr>
  -        </table>
  +      #foreach ($package in $node.selectNodes("./Packages/Package"))
  +          #if (! $package.get("error"))
  +        <subsection name="${package.attribute('name')}">
  +          #navbar ()
  +          <table>
  +            <tr>
  +              <th>Afferent Couplings</th>
  +              <th>Efferent Couplings</th>
  +              <th>Abstractness</th>
  +              <th>Instability</th>
  +              <th>Distance</th>
  +            </tr>
  +            <tr>
  +              <td>$package.valueOf("Stats/Ca")</td>
  +              <td>$package.valueOf("Stats/Ce")</td>
  +              <td>#formatAsNumber ($package.valueOf("Stats/A") "0%")</td>
  +              <td>#formatAsNumber ($package.valueOf("Stats/I") "0%")</td>
  +              <td>#formatAsNumber ($package.valueOf("Stats/D") "0%")</td>
  +            </tr>
  +          </table>
  +
  +          <table>
  +            <tr>
  +              <th>Abstract Classes</th>
  +              <th>Concrete Classes</th>
  +              <th>Used by Packages</th>
  +              <th>Uses Packages</th>
  +            </tr>
  +            <tr>
  +              <td>#classes ($package "AbstractClasses/Class")</td>
  +              <td>#classes ($package "ConcreteClasses/Class")</td>
  +              <td>#packages ($package "UsedBy/Package")</td>
  +              <td>#packages ($package "DependsUpon/Package")</td>
  +            </tr>
  +          </table>
  +        </subsection>
  +          #end
  +      #end
  +    </section>
  +
  +    ###################################################################
  +    <section name="Cycles">
  +      #navbar ()
  +
  +      #if (! $node.get("Cycles/Package"))
  +        <p>There are no cyclic dependancies.</p>
   
  +      #else
           <table>
             <tr>
  -            <th>Abstract Classes</th>
  -            <th>Concrete Classes</th>
  -            <th>Used by Packages</th>
  -            <th>Uses Packages</th>
  +            <th>Package</th>
  +            <th>Cyclic Dependencies</th>
             </tr>
  -          <tr>
  -            <td>#classes ($package "AbstractClasses/Class")</td>
  -            <td>#classes ($package "ConcreteClasses/Class")</td>
  -            <td>#packages ($package "UsedBy/Package")</td>
  -            <td>#packages ($package "DependsUpon/Package")</td>
  +          
  +          #foreach ($cycle in $node.selectNodes("./Cycles/Package"))
  +          <tr> 
  +            <td>$cycle.attribute('Name')</td>
  +            <td>
  +            #foreach ($package in $cycle.selectNodes("Package"))
  +              $package.value()<br/>
  +            #end
  +            </td>
             </tr>
  +          #end
  +
           </table>
  -      </subsection>
  -        #end
  -    #end
  +      #end
       </section>
   
       ###################################################################
  -    #section ("Cycles")
  +    <section name="Explanations">
  +      #navbar ()
   
  -    #if (! $node.get("Cycles/Package"))
  -      <p>There are no cyclic dependancies.</p>
  -
  -    #else
  +      <p>
  +        The following explanations are for quick reference and are
  +        lifted directly from the original <a
  +        href="http://www.clarkware.com/software/JDepend.html";>JDepend
  +        documentation</a>.
  +      </p>
  +      
         <table>
           <tr>
  -          <th>Package</th>
  -          <th>Cyclic Dependencies</th>
  +          <th>Term</th>
  +          <th>Description</th>
           </tr>
  -        
  -        #foreach ($cycle in $node.selectNodes("./Cycles/Package"))
  -        <tr> 
  -          <td>$cycle.attribute('Name')</td>
  +        <tr>
  +          <td>Number of Classes</td>
             <td>
  -          #foreach ($package in $cycle.selectNodes("Package"))
  -            $package.value()<br/>
  -          #end
  +            The number of concrete and abstract classes (and interfaces)
  +            in the package is an indicator of the extensibility of the
  +            package.
  +          </td>
  +        </tr>
  +        <tr>
  +          <td>Afferent Couplings</td>
  +          <td>
  +            The number of other packages that depend upon classes within
  +            the package is an indicator of the package's responsibility.
  +          </td>
  +        </tr>
  +        <tr>
  +          <td>Efferent Couplings</td>
  +          <td>
  +            The number of other packages that the classes in the package
  +            depend upon is an indicator of the package's independence.
  +          </td>
  +        </tr>
  +        <tr>
  +          <td>Abstractness</td> 
  +          <td>
  +            The ratio of the number of abstract classes (and interfaces)
  +            in the analyzed package to the total number of classes in
  +            the analyzed package.  The range for this metric is 0 to 1,
  +            with A=0 indicating a completely concrete package and A=1
  +            indicating a completely abstract package.
  +          </td>
  +        </tr>
  +        <tr>
  +          <td>Instability</td>
  +          <td>
  +            The ratio of efferent coupling (Ce) to total coupling (Ce /
  +            (Ce + Ca)). This metric is an indicator of the package's
  +            resilience to change.  The range for this metric is 0 to 1,
  +            with I=0 indicating a completely stable package and I=1
  +            indicating a completely instable package.
  +          </td>
  +        </tr>
  +        <tr>
  +          <td>Distance</td>
  +          <td>
  +            The perpendicular distance of a package from the idealized
  +            line A + I = 1. This metric is an indicator of the package's
  +            balance between abstractness and stability.  A package
  +            squarely on the main sequence is optimally balanced with
  +            respect to its abstractness and stability. Ideal packages
  +            are either completely abstract and stable (x=0, y=1) or
  +            completely concrete and instable (x=1, y=0).  The range for
  +            this metric is 0 to 1, with D=0 indicating a package that is
  +            coincident with the main sequence and D=1 indicating a
  +            package that is as far from the main sequence as possible. 
  +          </td>
  +        </tr>
  +        <tr>
  +          <td>Cycles</td>
  +          <td>
  +            Packages participating in a package dependency cycle are in
  +            a deadly embrace with respect to reusability and their
  +            release cycle. Package dependency cycles can be easily
  +            identified by reviewing the textual reports of dependency
  +            cycles. Once these dependency cycles have been identified
  +            with JDepend, they can be broken by employing various
  +            object-oriented techniques.
             </td>
           </tr>
  -        #end
         </table>
  -    #end
  -    </section>
  -
  -    ###################################################################
  -    #section ("Explanations")
  -
  -    <p>
  -      The following explanations are for quick reference and are
  -      lifted directly from the original <a
  -      href="http://www.clarkware.com/software/JDepend.html";>JDepend
  -      documentation</a>.
  -    </p>
  -    
  -    <table>
  -      <tr>
  -        <th>Term</th>
  -        <th>Description</th>
  -      </tr>
  -      <tr>
  -        <td>Number of Classes</td>
  -        <td>
  -          The number of concrete and abstract classes (and interfaces)
  -          in the package is an indicator of the extensibility of the
  -          package.
  -        </td>
  -      </tr>
  -      <tr>
  -        <td>Afferent Couplings</td>
  -        <td>
  -          The number of other packages that depend upon classes within
  -          the package is an indicator of the package's responsibility.
  -        </td>
  -      </tr>
  -      <tr>
  -        <td>Efferent Couplings</td>
  -        <td>
  -          The number of other packages that the classes in the package
  -          depend upon is an indicator of the package's independence.
  -        </td>
  -      </tr>
  -      <tr>
  -        <td>Abstractness</td> 
  -        <td>
  -          The ratio of the number of abstract classes (and interfaces)
  -          in the analyzed package to the total number of classes in
  -          the analyzed package.  The range for this metric is 0 to 1,
  -          with A=0 indicating a completely concrete package and A=1
  -          indicating a completely abstract package.
  -        </td>
  -      </tr>
  -      <tr>
  -        <td>Instability</td>
  -        <td>
  -          The ratio of efferent coupling (Ce) to total coupling (Ce /
  -          (Ce + Ca)). This metric is an indicator of the package's
  -          resilience to change.  The range for this metric is 0 to 1,
  -          with I=0 indicating a completely stable package and I=1
  -          indicating a completely instable package.
  -        </td>
  -      </tr>
  -      <tr>
  -        <td>Distance</td>
  -        <td>
  -          The perpendicular distance of a package from the idealized
  -          line A + I = 1. This metric is an indicator of the package's
  -          balance between abstractness and stability.  A package
  -          squarely on the main sequence is optimally balanced with
  -          respect to its abstractness and stability. Ideal packages
  -          are either completely abstract and stable (x=0, y=1) or
  -          completely concrete and instable (x=1, y=0).  The range for
  -          this metric is 0 to 1, with D=0 indicating a package that is
  -          coincident with the main sequence and D=1 indicating a
  -          package that is as far from the main sequence as possible. 
  -        </td>
  -      </tr>
  -      <tr>
  -        <td>Cycles</td>
  -        <td>
  -          Packages participating in a package dependency cycle are in
  -          a deadly embrace with respect to reusability and their
  -          release cycle. Package dependency cycles can be easily
  -          identified by reviewing the textual reports of dependency
  -          cycles. Once these dependency cycles have been identified
  -          with JDepend, they can be broken by employing various
  -          object-oriented techniques.
  -        </td>
  -      </tr>
  -    </table>
       </section>
   
     </body>
  
  
  
  1.1                  jakarta-turbine-maven/xdocs/stylesheets/junit.dvsl
  
  Index: junit.dvsl
  ===================================================================
  #######################################################################
  ## J U N I T     D V S L     S T Y L E S H E E T                     ##
  #######################################################################
  
  ## This stylesheet is used to transform the output of JUnit's xml
  ## generator.  The XML is transformed into a standard xdoc that can
  ## then be transformed (yet again) using whatever stylesheet is used
  ## to format one's site.
  ##
  ## Based on the XSL stylesheet junit-noframes.xsl from Ant.
  ##
  ## Version: $Id: junit.dvsl,v 1.1 2002/03/09 15:55:46 kaz Exp $
  
  #######################################################################
  ## G L O B A L    V A R I A B L E S                                  ##
  #######################################################################
  
  ## Used to facilitate quoting in the template.
  ##
  #set ($quote = '"')
  
  #######################################################################
  ## V E L O C I T Y    M A C R O S                                    ##
  #######################################################################
  
  ## Convert a string that represents a number using the specified
  ## pattern.  
  ##
  #macro (formatAsNumber $string $pattern)
      #set ($value = $context.toolbox.numbers.createNumber($string))
      $context.toolbox.formatter.formatNumber($value, $pattern)
  #end
  
  ## Prints a standard navbar for navigation.
  ##
  #macro (navbar)
        <p>
          [<a href="#Summary">summary</a>]
          [<a href="#Package List">package list</a>]
          [<a href="#Test Cases">test cases</a>]
        </p>
  #end
  
  ## Prints a standard header for a test suite.
  ##
  #macro (testSuiteHeader)
      <tr>
        <th>Name</th>
        <th>Tests</th>
        <th>Errors</th>
        <th>Failures</th>
        <th>Time(s)</th>
      </tr>
  #end
  
  ## Prints a standard header for a test case.
  ##
  #macro (testCaseHeader)
      <tr>
        <th>Name</th>
        <th>Status</th>
        <th>Type</th>
        <th>Time(s)</th>
      </tr>
  #end
  
  ## Prints the message from a failure.
  ##
  #macro (displayFailure $current)
      #if ($current.attribute("message"))
        $toolbox.htmlescape.getText($current.attribute("message"))
      #else
        N/A
      #end
      <p/>
      <code>
        $toolbox.htmlescape.getText($current.value())
      </code>
  #end
  
  #######################################################################
  ## T E M P L A T E    D E F I N I T I O N S                          ## 
  ####################################################################### 
  
  ## Matches the root element of the JUnit XML report.
  ##
  #match ("testsuites")
  <?xml version="1.0"?>
  <document>
  
    <properties>
      <title>JUnit Test Results</title>
    </properties>
  
    <body>
      ###################################################################
      <section name="Unit Test Results">
        #navbar ()
        <p>
          The following document contains the results of the <a
          href="http://www.junit.org";>JUnit</a> tests.  
        </p>
      </section>
  
      ###################################################################
      <section name="Summary">
        #navbar ()
        #set ($testCount    = $node.valueOf("sum(testsuite/@tests)"))
        #set ($errorCount   = $node.valueOf("sum(testsuite/@errors)"))
        #set ($failureCount = $node.valueOf("sum(testsuite/@failures)"))
        #set ($timeCount    = $node.valueOf("sum(testsuite/@time)"))
        #set ($successRate  = $node.valueOf("($testCount - $failureCount - 
$errorCount) div $testCount"))
        <table>
          <tr>
            <th>Tests</th>
            <th>Failures</th>
            <th>Errors</th>
            <th>Success rate</th>
            <th>Time(s)</th>
          </tr>
          <tr>
            <td>#formatAsNumber ($testCount    "0")</td>
            <td>#formatAsNumber ($failureCount "0")</td>
            <td>#formatAsNumber ($errorCount   "0")</td>
            <td>#formatAsNumber ($successRate  "0.00%")</td>
            <td>#formatAsNumber ($timeCount    "0.000")</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">
        #navbar ()
        <table>
            #testSuiteHeader ()
            #foreach ($testsuite in $node.selectNodes("./testsuite[not(./@package = 
preceding-sibling::testsuite/@package)]"))
            #set ($package = $testsuite.attribute('package'))
            #set ($quotedPackage = "$quote$package$quote")
            #set ($testCount     = $node.valueOf("sum(./testsuite[./@package = 
$quotedPackage]/@tests)"))
            #set ($errorCount    = $node.valueOf("sum(./testsuite[./@package = 
$quotedPackage]/@errors)"))
            #set ($failureCount  = $node.valueOf("sum(./testsuite[./@package = 
$quotedPackage]/@failures)"))
            #set ($timeCount     = $node.valueOf("sum(./testsuite[./@package = 
$quotedPackage]/@time)"))
          <tr>
            <td><a href="#$package">$package</a></td>
            <td>#formatAsNumber ($testCount    "0")</td>
            <td>#formatAsNumber ($failureCount "0")</td>
            <td>#formatAsNumber ($errorCount   "0")</td>
            <td>#formatAsNumber ($timeCount    "0.000")</td>
          </tr>
            #end
        </table>
        <p>
          Note: package statistics are not computed recursively, they only
          sum up all of its testsuites numbers.
        </p>
    
        #foreach ($testsuite in $node.selectNodes("./testsuite[not(./@package = 
preceding-sibling::testsuite/@package)]"))
        #set ($package = "$testsuite.attribute('package')")
        #set ($quotedPackage = "$quote$package$quote")
        <subsection name="$package">
          #navbar ()
          <table>
            #testSuiteHeader ()
            #foreach ($test in $node.selectNodes("/testsuites/testsuite[./@package = 
$quotedPackage]"))
            <tr>
              <td><a href="#$test.attribute('name')">$test.attribute('name')</a></td>
              <td>#formatAsNumber ($test.attribute('tests')    "0")</td>
              <td>#formatAsNumber ($test.attribute('errors')   "0")</td>
              <td>#formatAsNumber ($test.attribute('failures') "0")</td>
              <td>#formatAsNumber ($test.attribute('time')     "0.000")</td>
            </tr>
            #end
          </table>
        </subsection>
        #end
      </section>
  
      ###################################################################
      <section name="Test Cases">       
        #navbar ()
        #foreach ($testsuite in $node.selectNodes("./testsuite"))
        <subsection name="$testsuite.attribute('name')">
          #navbar ()
          <table>
            #testCaseHeader ()
  
            ## test can even not be started at all (failure to load the class)
            ## so report the error directly
            ##
            #foreach ($error in $testsuite.selectNodes("./error"))
            <tr> <td colspan="4"> #displayFailure ($error) </td> </tr>
            #end
  
            #foreach ($testcase in $testsuite.selectNodes("./testcase"))
            <tr>
              <td>$testcase.attribute("name")</td>
              #if ($testcase.get("failure"))
              <td>Failure</td>
              <td> #displayFailure ($testcase.selectSingleNode("failure")) </td>
              #elseif ($testcase.get("error"))
              <td>Error</td>
              <td> #displayFailure ($testcase.selectSingleNode("error")) </td>
              #else
              <td>Success</td>
              <td></td>
              #end
              <td>#formatAsNumber ($testcase.attribute("time") "0.000")</td>
            </tr>
            #end
          </table>
        </subsection>
        #end
      </section>
    </body>
  </document>
  #end
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to