Apache Maven 1.x has reached its end of life, and is no longer supported. For more information, see the announcement. Users are encouraged to migrate to the current version of Apache Maven.

Frequently Asked Questions


  1. How do I email a test report?


How do I email a test report?

The following sample code will email a test report if there are any failures:

<postGoal name="maven-junit-report-plugin:report">
  <j:if test="${maven.test.failure}">
    <j:set var="mailReport" value="${test.mail.report}" />
    <j:if test="${mailReport}">
      <attainGoal name="mail-test-report" />

<goal name="mail-test-report">
  <ant:style in="${maven.build.dir}/TESTS-TestSuites.xml" out="${maven.build.dir}/junit-report-mail.html" style="${basedir}/overview-summary.xsl" />

  <ant:mail messageMimeType="text/html" messageFile="${maven.build.dir}/junit-report-mail.html"
            subject="[BUILD] JUnit Test Results for ${pom.artifactId}: ${TODAY}" tolist="${pom.build.nagEmailAddress}
    <ant:from name="Build Master" address="someone@nowhere.com.au" />

Include this in your maven.xml file, and set the property test.mail.report to true for the users that you want to send the mail from (typically just you continuous integration environment).

Note that you have to include Xalan in your dependencies for this particular example (see the main Maven FAQ for more information), and provide the overview-summary.xsl file in your project's base directory. An example one is distributed with Ant in etc/junit-noframes.xsl.

If you want to receive successful reports, exclude the <j:if test="${maven.test.failure}"> condition.