I just had test in a Maven build fail with
java.lang.OutOfMemoryError: Java heap space
It turns out that when Maven fork a new process to run the tests in, it doesn’t seem to honor your MAVEN_OPTS settings and pass them to the new process. The solution may be to set the heap size for the Surefire, and possible Failsafe, plugin. This can be done with the optional argLine parameter.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.10</version> <configuration> <argLine>-Xmx1024m</argLine> </configuration> </plugin>
This solved my urgent problem, getting the build to pass. My long term problem is now to understand why the test need more memory then before.