事象
mvn testでJUnitテスト実行失敗。下記のエラーログがでた。
The forked VM terminated without saying properly goodbye. VM crash or System.exit called
"forked"とは?
「フォークする」= テストするためにJVM内にプロセスを生成すること
mavenでJUnitテスト実行するときには「maven-surefire-plugin」というプラグイン経由で実行する(のが普通だと思ってる)のだが、テスト用に生成するプロセス数は↓のようにforkCountで制御できる。
例) フォークする最大プロセス数を「3」に設定する
<project>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkCount>3</forkCount>
<argLine>-Xmx1024m</argLine>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
原因
1つのプロセスでさばくにはテスト負荷が高すぎて死んだ。
The default setting is forkCount=1/reuseForks=true, which means that maven-surefire-plugin creates one new JVM process to execute all tests in one Maven module.
https://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html#
対処方法
forkCountのデフォルト値は「1」なので、これを「3」に変更して実行したらmvn testうまくいった(´_ゝ`)
参考