Skip to content
mipe edited this page Oct 31, 2014 · 14 revisions

Surefire to PDF Maven Plugin

The Surefire to PDF Maven Plugin converts Surefire reports into a PDF. Additionally scenario descriptions can be added that provide detailed explanation for end users. The plugin has the ability to include repeated single test runs of a suite into the report. This helps with creating reports for tests that are correctly implemented, but failed due to testing environment problems. The benefit of this is that the user responsible for the report generation does not have to rerun the whole suite again in the hope of getting a perfect run and instead can just repeat the single test case and include this result into the report.

Installation

To use the Maven plugin you have to add it into the build/plugins section of your project.

<plugin>
  <groupId>org.cdlflex</groupId>
  <artifactId>sf2pdf-maven-plugin</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</plugin>

The plugin supports the following parameters:

Parameter Description Default
reportDirectory Location of the surefire reports. ${project.build.directory}/surefire-reports
sf2pdfDirectory Location of the folder containing the 'report.properties' file and the 'scenario'-directory with the scenario XML files. src/test/resources/sf2pdf
outputDirectory The directory where the reports should be created. ${project.build.directory}

Configuration and Customization

sf2pdf Directory

The sf2pdf directory contains the 'report.properties' file, as well as a 'scenarios' directory which contains all the scenario files for the tests.

sf2pdf
|-- report.properties
`-- scenarios
    |   `-- subdirectory
    |       `-- scenario3.xml
    |-- scenario1.xml
    |-- scenario2.xml

report.properties file

The property file contains additional info about the report which does not belong to simple test cases, like data/texts used on the frontpage of the report or in the footnote:

version=${project.version}
headline1=Test Report
headline2=Version {0}
contact=Contact
contactText=Test Tester1 (TT1), Test Tester2 (TT2)
email1=testmail1
email2=testmail2
[email protected]
[email protected]
footnote1=Test footnote

Scenario Files

Scenario files contain detailed meta-descriptions for each test case which describe the test steps in a way that humans who cannot read code can understand them. A complete sample of a scenario XML file could look like this:

<testScenario>
  <expectedResults>
    <expectedResult>The expected test result.</expectedResult>
  </expectedResults>
  <name>DummyTest1 name</name>
  <preconditions/>
  <scenarioNumber>1</scenarioNumber>
  <steps>
    <step>
      <description>Do some stuff</description>
    </step>
    <step>
      <description>Do some other stuff</description>
    </step>
  </steps>
  <tags>
    <tag>
      <name>Acceptance test</name>
    </tag>
  </tags>
  <testCategory>GENERAL</testCategory>
  <testClass>org.cdlflex.DummyTest1</testClass>
  <testCommitter>QS_TEAM</testCommitter>
  <testName>testSuccess</testName>
  <testPriority>HIGH</testPriority>
</testScenario>

Execution

To execute the plugin after successful installation and after having created some surefire reports by running tests, simply call the 'make' goal of the plugin by typing

mvn org.cdlflex:sf2pdf-maven-plugin:make

You can shorten that by adding the following into the settings section of your .m2/settings.xml:

<pluginGroups>
  <pluginGroup>org.cdlflex</pluginGroup>
</pluginGroups>

After this you only have to type:

mvn sf2pdf:make