I'm trying to pass a VM argument into Maven, specifically for a suite of tests run by failsafe.
我正在尝试将VM参数传递给Maven,特别是针对由failafe运行的一组测试。
My pom.xml looks like this:
我的pom.xml看起来像这样:
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<argLine>-Dtest.data=true</argLine>
</configuration>
<version>2.7.2</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
...
When I run the command mvn clean verify
the tests that rely on test.data being set to true are failing. However, when I run the command mvn -Dtest.data=true clean verify
the tests all pass. I need the argument to be set inside the pom for my CI environment.
当我运行命令mvn clean时,验证依赖于test.data设置为true的测试是否失败。但是,当我运行命令mvn -Dtest.data = true时,请验证测试是否全部通过。我需要将参数设置在我的CI环境的pom中。
Am I missing something here?
我在这里错过了什么吗?
Thanks in advance,
提前致谢,
Pete
2 个解决方案
#1
3
Use the <systemPropertyVariables>
element to set system properties (I don't see where <argLine>
is mentioned in the documentation, where did you find it?):
使用
<configuration>
<systemPropertyVariables>
<test.data>true</test.data>
</systemPropertyVariables>
</configuration>
#2
0
Ok it turns out that the integration tests that I was trying to run needed to have this argument passed into the Tomcat plugin not the Failsafe plugin. Thanks for your help guys!
好吧事实证明,我试图运行的集成测试需要将此参数传递给Tomcat插件而不是Failsafe插件。谢谢你的帮助!
#1
3
Use the <systemPropertyVariables>
element to set system properties (I don't see where <argLine>
is mentioned in the documentation, where did you find it?):
使用
<configuration>
<systemPropertyVariables>
<test.data>true</test.data>
</systemPropertyVariables>
</configuration>
#2
0
Ok it turns out that the integration tests that I was trying to run needed to have this argument passed into the Tomcat plugin not the Failsafe plugin. Thanks for your help guys!
好吧事实证明,我试图运行的集成测试需要将此参数传递给Tomcat插件而不是Failsafe插件。谢谢你的帮助!