surfire单元测试添加jvm参数
生活随笔
收集整理的这篇文章主要介绍了
surfire单元测试添加jvm参数
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
有人配置jvm 参数可以是上面形式:
<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>2.19.1</version><configuration><systemPropertyVariables><jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile></systemPropertyVariables><argLine>${argLine} -XX:NewSize=128m -XX:MaxNewSize=512m -XX:PermSize=128m -XX:MaxPermSize=768m</argLine></configuration></plugin>
jacoco 源码:
如果添加
-noverify -XX:-UseSplitVerifier <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>2.19.1</version><configuration><systemPropertyVariables><jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile></systemPropertyVariables><argLine>${argline} -noverify -XX:-UseSplitVerifier -XX:NewSize=128m -XX:MaxNewSize=512m -XX:PermSize=128m -XX:MaxPermSize=768m</argLine></configuration></plugin>会报错!!!!!!!!!!!!!!!
去掉${argLine} 改成-noverify -XX:-UseSplitVerifier -XX:NewSize=128m -XX:MaxNewSize=512m -XX:PermSize=128m -XX:MaxPermSize=768m 才正常!!!!
为什么呢??????????????????????
官网上配置参数: 连接http://maven.apache.org/components/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html
<plugins> [...]<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>2.20.1</version><configuration><forkCount>3</forkCount><reuseForks>true</reuseForks><argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine><systemPropertyVariables><databaseSchema>MY_TEST_SCHEMA_${surefire.forkNumber}</databaseSchema></systemPropertyVariables><workingDirectory>FORK_DIRECTORY_${surefire.forkNumber}</workingDirectory></configuration></plugin> [...] </plugins>讲解:
<argLine>${argLine} -XX:NewSize=128m -XX:MaxNewSize=512m -XX:PermSize=128m -XX:MaxPermSize=768m</argLine></configuration>其实是${argLine}变量和后面参数的拼接,argLine变量上面又没有声明,所以会出错,有的构建直接会取jacoco中默认的argLine变量,因为jacoco插件中会默认声明,且初始是空字符串,所有构建又不会报错。
所以正确方式是没有${argLine}的。jacoco 源码:
总结
以上是生活随笔为你收集整理的surfire单元测试添加jvm参数的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: surfire 单元测试 使用了mock
- 下一篇: jenkins 对 maven对应的 j