Send a mail if the testcases fail. This is usefull if you have desided not to have the full build failing if your testcases fail (for any reason, usefull or not...).

The plugin computes the test results from the previous run of the mave-surefire-plugin, thefore the tests should have been executed.

This goal is able to send you the HTML report from the maven-surefire-report-plugin, but this is only possible if postman is executed after the report plugin. This can be achieved by setting the execution phase to site. If this is not the case, you will only receive a pure text mail.

The property groovyCondition allows you to redefine the condition to send the mail. e.g. one can define that there must not be more then 20 skipped test cases (skipped > 20). The default condition sends mails if there are any errors. The following variables are available for usage in the condition:

  • errors: number of all errors while running surefire
  • skipped: number of all skipped test cases
  • failures: number of all failures in the test cases
  • total: number of all test cases

Other (usefull or not...) examples:

  • errors > 0 : sends a mail only if there are errors
  • skipped > failures : sends mails if there are more skipped then failed test cases
  • total == skipped : Sends mails if all tests are skipped

To avoid problems with XML syntax, one can use a CDATA element. The default only sends a mail if there are errors or failures, but ignores the skipped ones.

btw. with JUnit a test gets skipped if you add the @Ignore (org.junit.Ignore) annotation to it.

Default value is: errors > 0 || failures > 0

            <id>send surefire notification</id>
                <subject>Test Surefire</subject>
                <groovyCondition><![CDATA[errors < skipped]]></groovyCondition>