More Heapspace for JUnit tests on Hudson
At DFKI we are running Maven2 along with Hudson for Continuous Integration of our research prototype applications.
Recently, I recognized, that some tests were running fine when executed on my local machine as normal JUnit tests in Eclipse. But running a “mvn verify” on the same project with these tests brought Test errors for the same tests.
A look at the surefire reports in target/surefire-reports/ revealed that the errors were cause by Java OutOfMemory exceptions. In Hudson, they just look like this:
Error Message
Java heap space
Stacktrace
java.lang.OutOfMemoryError: Java heap space
I literally spent hours on playing around with MAVEN_OPTS in Eclipse and Hudson. None of these settings had any impact on the execution of the JUnit test by Maven.
Finally, I found out, that it is the maven-surefire-plugin which needs additional memory. The default configuration for surefire is inherited implicitly from the super pom. You have to override this config by adding this section to your project’s pom.xml:
</build>
</plugins>
</build><plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx512m</argLine>
</configuration>
</plugin>
</plugins>
</build>