Jenkins, the brilliant Continuous Integration build server, has a bit of a problem with the Maven surefire jUnit test plugin. Last sunday, I discovered that our Jenkins build server suddenly started ignoring test failures. While the logfile clearly states that the Unittests contain failures, Jenkins marks the builds as “stable”.
After some digging around, I found that even though Jenkins explicitly tells you in the logfile that it will fail the build, it will not do so if the Surefire XML reports are not generated. In our case, somebody in the team decided that the generation of the XML Surefire reports was taking too long and had disabled them in the Maven pom.xml.
In order to solve this, I re-enabled the XML reports and voila, Jenkins happily started reporting errors again. Here is the correct Surefire plugin configuration for you to use in your maven pom.xml file:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.8</version> <configuration> <!-- Please note that Jenkins needs Surefire XML reports in order for detection to work. Keep this property set to false. --> <disableXmlReport>false</disableXmlReport> </configuration> </plugin>
Disabling the disableXmlReport option… some programmers just love double negatives. What’s wrong with enableXmlReport=true?
One of my pet peeves as well. Personally, I think “generateXMLReport=true” is even better.
You’re thinking too small, even better would be <report>xml</report>, or enabled(true/1/on/yes)
Thanks very much man! You made my day! I was having this problem but with Failsafe (a fork of Surefire) in Jenkins and I could make it work by adding a Post Build step to copy the reports from the acceptance-test module to the “root”/target directory. Thank you!!!