Saita
Saita

Reputation: 1044

Spring-boot application test - memory issues

I have a spring-boot test that starts my application and run some tests on it.

I am having a problem setting the application heap size.

When I run it through maven and surefire with memory parameters set, it all works, but trying to run it from my IDE (Intellij) doesn't, and I get java.lang.OutOfMemoryError: Java heap space.

@RunWith(Parameterized.class)
@SpringApplicationConfiguration(classes = MyApplication.class)
@WebAppConfiguration
public class MyTest {

    public MyTest(String name, URL url) {
        this.url = url;
    }

    @Parameterized.Parameters...
    public static Iterable<Object[]> tests() throws IOException {
       ....
    }

    @Before
    public void setUpContext() throws Exception {
        new TestContextManager(getClass()).prepareTestInstance(this);
    }


    @Test
    public void doSomething() throws Exception {
       ...
    }
}

Upvotes: 0

Views: 2640

Answers (1)

Saita
Saita

Reputation: 1044

I figured it out.

Apparently, the surefire plugin definition on my pom has precedence over intellij run configurations.

I needed -Xmx1024 but it was:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <inherited>true</inherited>
            <configuration>
                <argLine>-Xmx256m -XX:MaxPermSize=256m</argLine>
               </configuration>
        </plugin>

Upvotes: 1

Related Questions