2017-10-25 15 views
0

私はアプリケーションを起動し、いくつかのテストを実行するスプリングブートテストを行っています。スプリングブートアプリケーションテスト - メモリの問題

アプリケーションヒープサイズの設定に問題があります。

メモリパラメータを設定してmavenとsurefireを実行すると、すべて動作しますが、IDE(Intellij)から実行しようとすると、java.lang.OutOfMemoryError:Javaヒープスペースが発生します。

@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 { 
     ... 
    } 
} 
+0

編集し、実行コンフィギュレーション、およびメモリオプションを設定します。 –

+0

この記事のようにIDEのヒープサイズを設定しましたか?[JVMオプションとプラットフォームプロパティの設定](https://intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options- and-platform-properties)? – LHCHIN

+0

申し訳ありませんが、言及するのを忘れましたが、実行コンフィギュレーションでメモリパラメータを設定しました。テスト用のアプリケーションを実行しているVMには渡されないようです。 – Saita

答えて

0

私はそれを理解しました。

明らかに、私のpomのsurefireプラグインの定義は、intellijの実行構成よりも優先されます。

私は-Xmx1024を必要と、それはだった:

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

'-XX:MaxPermSize'はJava 7以前のバージョンでのみ動作します –