freshmeat.net

linuxlinks.com



 Use OpenOffice.org
Friends of the OSL

opensource.org

OSI Certified Open Source Software


Advanced topics

 

Running the examples

If you want to try JUnit PDF Report with the examples provided
by this project, you need this configuration:

Software:

Install Java
JDK 1.4 or higher.

Install Ant
version 1.6.2 or higher somewhere on your filesystem.

Install JUnit jar
version 3.8 or higher in the ant/lib directory.

Install Fop jars
version 0.20.5 or later ( from release JUNITPDFREPORT_0_3 on it
also works with fop-0.90alpha1, fop-0.91beta and fop-0.92beta) somewhere on
your filesystem.


See bug
1394999: image rendering differs between
fop 0.90 and 0.91
for a known
issue in fop-0.91beta. This is resolved in fop-0.92beta


Note:

Release 0.6 is the last release for JUnit 3.8 / Ant 1.6 support.

Starting with release 0.7, target versions are JUnit 4 and Ant 1.7 (and Java 1.5).

(Snapshot releases starting from 2006-03-10 are showing progress for JUnit 4 support).

Environment variables:

Unix/Linux

ANT_HOME=/directory/of/your/ant/installation
JAVA_HOME=/directory/of/your/jdk/installation
PATH=<your path>:/directory/of/your/ant/installation/bin

Windows

ANT_HOME=x:\directory\of\your\ant\installation
JAVA_HOME=x:\directory\of\your\jdk\installation
PATH=<your path>;x:\directory\of\your\ant\installation\bin
(where x: is the name of your drive)

 JUnit PDF Report source files:

Get the sources for JUnit PDF Report either from cvs, or
from the source distribution,
and install them somewhere on your file system.

In the root directory of your JUnit PDF Report installation,
edit the build.properties.sample file.

Change the property fop.dir to point to the Fop jars:

 

fop.dir=/path/to/your/fop/libraries

You need these libraries (for fop-trunk):

avalon-framework-4.2.0.jar

commons-io-1.1.jar

commons-logging-1.0.4.jar

xmlgraphics-commons*.jar

fop.jar

 ! Save the file as build.properties !

You are now ready to try JUnit PDF Report.

On your command prompt, navigate to the root directory of your
JUnit PDF Report installation.

To run the examples, type:

> ant run

These PDF reports are created:

build/example_run/generated/junit.pdf (version < 0.7)

build/example_run/themes/default/generated/junit.pdf (version ≥ 0.7)

build/example_run/themes/brief/generated/junit.pdf

build/example_run/themes/structural/generated/junit.pdf

build/example_run/themes/graphical/generated/junit.pdf

To run the test suite, type:

> ant test

This PDF reports is created:

build/test/test_results/junit.pdf

 

Using JUnit PDF Report in your
project

back to top

Place junit-noframes.xsl(and extra-documentation.xsl
if you're using the default stylesheet) and build-junitpdfreport.xml somewhere in your
project directory.

Add this line to your Ant build.xml script:

<import file="build-junitpdfreport.xml"/>

Add this target to your Ant build.xml script:

<target name="testreport-pdf">
  <mkdir dir="pdfreport"/>
  <path id="fop.path">
    <fileset dir="${fop.dir}" includes="*.jar"/>
  </path>

  <junitpdfreport todir="pdfreport" styledir="/where/you/placed/the/xsl/files"> 
    <fileset dir="/location/to/your/junit/xml/testresults"> 
      <include name="TEST-*.xml"/> 
    </fileset> 
  </junitpdfreport> 
</target>

Add this property to your Ant build.properties
file:

fop.dir=/path/to/your/fop/libraries

From the command prompt, run:

> ant testreport-pdf

You will find the PDF report in the pdfreport subdirectory.

 

How to create a customized description in pdf?

back to top

contibution by falseawake.

You want a customized description in your pdf-file which
contains testresults.
Resume that you have a Testclass
called "TestIndex.java" and a Testmethod called "indexTest".

Edit your file junitpdfreport/default/extra-documentation.xsl like following

<xsl:stylesheet
xmlns:xsl=http://www.w3.org/1999/XSL/Transform
xmlns:fo=http://www.w3.org/1999/XSL/Format
xmlns:stringutils="xalan://org.apache.tools.ant.util.StringUtils"
version="1.0">

<xsl:template name="unittest.description">
<fo:block font-size="11pt" space-before.optimum="20pt">

Description
</fo:block>
</xsl:template>

<xsl:template match="testsuite"
mode="testcase.description">
<xsl:choose>
<xsl:when test="string(@name) = 'TestIndex'">
    <fo:block font-size="11pt"
space-before.optimum="20pt">

       
Description
    </fo:block>
    <fo:block
linefeed-treatment="preserve"
white-space-collapse="false" font-size="9pt"
space-before.optimum="20pt">
       
Your test description here
    </fo:block>
</xsl:when>
</xsl:choose>

</xsl:template>

<xsl:template name="signoff">

<fo:block space-before.optimum="20pt"
space-after.optimum="15pt" border-style="solid"
border-color="blue" border-width="0.5pt">

<fo:block space-before.optimum="3pt"
space-after.optimum="15pt">
Sign-off area:
</fo:block>

<fo:block space-before.optimum="100pt"
space-after.optimum="15pt">

</fo:block>

</fo:block>
</xsl:template>
</xsl:stylesheet>
            

Powered by Drupal - Design by Artinet