freshmeat.net

linuxlinks.com



 Use OpenOffice.org
Friends of the OSL

opensource.org

OSI Certified Open Source Software


Understanding PDF translation

The ant target junitreport aggregates testresults in a summary xml document, typically named TESTS-TestSuites.xml.

JUnit PDF Report converts the summary file to an XSL-FO xml document.

That document is handed over to FOP for PDF rendering.

junitreport aggregated results layout

This section explains the layout of the summary file created by ant's junitreport target.

<testsuites>     1 the aggregated result of all junit testfiles

  <testsuite>    * the output from a single TestSuite

    <properties> 1 the defined properties at test execution

      <property> * name/value pair for a single property

    <testcase>   * the results from executing a test method

    <system-out> 1 data written to System.out during the test run

    <system-err> 1 data written to System.err during the test run


Considerations:

A package can appear in multiple testsuite instances.

To correctly calculate package statistics, data from all instances for that package has to be summarized.

conversion to XSL-FO

This section explains how the junitreport summary file is processed

Summary section

The summary section of the PDF report aggregates:

  • the total number of tests
  • the total number of errors
  • the total number of failures
  • the total execution time

It also derives the success rate using the formula: (tests - errors - failures) / tests.

xpath: /testsuites

calculations:


<xsl:variable name="testCount" select="sum(testsuite/@tests)"/>

<xsl:variable name="errorCount" select="sum(testsuite/@errors)"/>

<xsl:variable name="failureCount" select="sum(testsuite/@failures)"/>

<xsl:variable name="timeCount" select="sum(testsuite/@time)"/>

<xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/>

Packages section

This section is divided in two parts:

  • part 1: all packages covered in the unit tests, and their statistics
  • part 2: per package, all testsuites and their statistics

Part 1 of the packages section of the PDF report aggregates:

  • the total number of tests per package
  • the total number of errors per package
  • the total number of failures per package
  • the total execution time per package

Part 2 of the packages section of the PDF report displays, grouped by package:

  • the total number of tests per testsuite
  • the total number of errors per testsuite
  • the total number of failures per testsuite
  • the total execution time per testsuite

xpath: /testsuites/testsuite[not(./@package = preceding-sibling::testsuite/@package)]

sort: @package

The not qualifier skips a package if it has already been visited in a previous testsuite (see Considerations).

calculations:



Part 1:


<xsl:for-each select="./testsuite[not(./@package = preceding-sibling::testsuite/@package)]">

  <xsl:sort select="@package"/>

  <xsl:variable name="testsuites-in-package" select="/testsuites/testsuite[./@package = current()/@package]"/>

  <xsl:variable name="testCount" select="sum($testsuites-in-package/@tests)"/>

  <xsl:variable name="errorCount" select="sum($testsuites-in-package/@errors)"/>

  <xsl:variable name="failureCount" select="sum($testsuites-in-package/@failures)"/>

  <xsl:variable name="timeCount" select="sum($testsuites-in-package/@time)"/>



Part 2:


<xsl:for-each select="./testsuite[not(./@package = preceding-sibling::testsuite/@package)]">

  <xsl:sort select="@package"/>



  select="/testsuites/testsuite[./@package = current()/@package]"


    @tests

    @errors

    @failures

    @time

Testcases section

This section shows each testsuite in detail:

  • the testcases covered in the testsuite
  • the status of each testcase
  • the error message in case of failure or error
  • statistics
  • System.out and System.err log, if available

xpath: testsuite

sort: @name

calculations:


<xsl:for-each select="testsuite">

  <xsl:sort select="@name"/>



  select="./testcase"



    <xsl:choose>

      <xsl:when test="failure"><xsl:text>Failure</xsl:text></xsl:when>

      <xsl:when test="error"><xsl:text>Error</xsl:text></xsl:when>

      <xsl:otherwise><xsl:text>Success</xsl:text></xsl:otherwise>

    </xsl:choose>

    @time


  system-out

  system-err

Powered by Drupal - Design by Artinet