[英]How to run junit tests by maven in terminal with JVM arguments
As mentioned in here we can run test methods using, 正如提到这里 ,我们可以用跑的测试方法,
mvn -Dtest=TestCircle#xyz test
But I need to set some JVM arguments before run the test case. 但是我需要在运行测试用例之前设置一些JVM参数。 Like I need to use 就像我需要使用
-Djava.security.manager -Djava.security.policy=mypolicy.policy
How can I tell maven to consider those when running a test case. 如何在运行测试用例时告诉maven考虑这些问题。
Two possible solutions: 两种可能的解决方
First, if your JVM arguments are applicable to all tests, you can add such information as a configuration item for Surefire as follows: 首先,如果您的JVM参数适用于所有测试,您可以添加诸如Surefire的配置项之类的信息,如下所示:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
...
<configuration>
<argLine>-Djava.security.manager -Djava.security.policy=mypolicy.policy</argLine>
</configuration>
</plugin>
Second, if such JVM arguments are to be applied on a test-by-test basis, they can be specified on the command line as follows: 其次,如果要在逐个测试的基础上应用此类JVM参数,可以在命令行上指定它们,如下所示:
mvn -Dtest=TestCircle#xyz test -DargLine="-Djava.security.manager -Djava.security.policy=mypolicy.policy"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.