Previously i have talked about setting Java Heap Memory in Maven.
But i find that the OutOfMemoryError still exists when running the JUnit test during build. =.=
After searching in Google, i realize that in Maven…
JUnit tests ignore the environment variable MAVEN_OPTS and the JVM settings in Run Configurations.
So if u have OutOfMemoryError when running unit test in Maven, you have to set the Java Heap Memory in the maven-surefire-plugin inside the pom.xml.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.5</version> <configuration> <argLine>-Xms512m -Xmx512m</argLine> </configuration> </plugin>
- Keith Chapman – Increasing memory of JUnit TestCases in Maven2
- Draptik – Maven2 Heap Overflow in JUnit test cases: Howto increase memory