I have a multi-module Maven project with two modules being Spring Boot applications. Each of them has a simple test that the Spring application context loads successfully (my tests are very similar to this one). I run this tests with the following command in project root:
mvn -P IntegrationTests clean test
During context initialization things go out of my control, the application "eats" memory (heap size grows quickly to 4 gigabytes) and then the context fails to start with java.lang.OutOfMemoryError: PermGen space error (yes, I run it in Java 7).
Monitoring task manager during testing I noticed that maven spawns two new processes that have something to do with surefire plugin. I have no idea where it comes from, because I don't add the surefire plugin in my pom.xml.
Previously when encountered the same error somewhere I specified VM options (-Xmx256m -Xms128m -XX:MaxPermSize=256m -XX:PermSize=128m for example) and the problem was solved.
This time I tried to
- set
MAVEN_OPTSenvironment variable - set VM options (when running
mvn testin IntelliJ IDEA) - it affected main java process but not its children - add
-Drun.jvmArguments="..."in command line
but the problem persists.
Please help me to fight the OutOfMemoryError in tests.

Add Surefire plugin explicitly to module-specific pom.xml and configure VM options there. I like this solution because this way VM options are