Sky*_*olf 4 mockito surefire maven jacoco
我正在使用mockito 1.8.3,jacoco 0.72和maven 3.0.5 surefire插件(2.12.4)执行单元测试并生成覆盖报告,它工作正常.
随着越来越多的测试被添加,它开始不起作用.我在测试执行期间不断遇到内存不足错误,无法找出找出问题的方法.
我有大约1800多个测试用例,mockito作为模拟工具.如果我在测试阶段之前没有使用"org.jacoco:jacoco-maven-plugin:prepare-agent"在maven测试期间运行jacoco,那么它工作正常,但只要我添加jacoco代理,我就得到了PermGen的OOO问题.
我已经通过修改MAVEN_OPTS(由于surefire将分叉一个新进程不应该工作)和pom中的surefire argline参数将PermGen添加到2GB,但它没有多大帮助.
通过向surefire插件添加参数,我尝试在OOO发生时获取核心转储,但从未在任何文件夹中看到转储文件.我怀疑我的JVM设置不适用于surefire插件,但不确定是什么问题.有人可以帮我一个忙吗?谢谢.
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<inherited>true</inherited>
<configuration>
<properties>
<property>
<name>argLine</name> <value>-server -ea -XX:-UseSplitVerifier -XX:MaxPermSize=2g -Xmx3g -XX:+HeapDumpOnOutOfMemoryError </value>
</property>
<property>
<name>forkMode</name>
<value>once</value>
</property>
<property>
<name>reportFormat</name>
<value>plain</value>
</property>
<property>
<name>skipTests</name>
<value>${maven.test.skip}</value>
</property>
</properties>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
您需要为maven-surefire-plugin设置内存,如下所示:
<plugins>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
<systemPropertyVariables>
<databaseSchema>MY_TEST_SCHEMA_${surefire.forkNumber}</databaseSchema>
</systemPropertyVariables>
</configuration>
</plugin>
[...]
</plugins>
Run Code Online (Sandbox Code Playgroud)