【问题标题】:VM Arguments with maven-failsafe-plugin [closed]带有 maven-failsafe-plugin 的 VM 参数 [关闭]
【发布时间】:2011-07-30 23:51:43
【问题描述】:

我正在尝试将 VM 参数传递给 Maven,特别是针对故障安全运行的一组测试。

我的 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>
...

当我运行命令 mvn clean verify 时,依赖于 test.data 设置为 true 的测试失败。但是,当我运行命令 mvn -Dtest.data=true clean verify 时,测试全部通过。我需要在我的 CI 环境的 pom 中设置参数。

我错过了什么吗?

提前致谢,

皮特

【问题讨论】:

  • 第一个建议是更新到 Maven-FailSafe-Plugin 的 2.8。你在 fork JVM 吗?
  • 我已更新到 2.8,但仍然无法正常工作。我怎么知道我是否在分叉 JVM?我不相信我是。
  • 默认情况下说你正在分叉。

标签: java maven continuous-integration build-automation maven-plugin


【解决方案1】:

使用&lt;systemPropertyVariables&gt;元素to set system properties(我没看到文档中提到&lt;argLine&gt;,你在哪里找到的?):

<configuration>
    <systemPropertyVariables>
        <test.data>true</test.data>
    </systemPropertyVariables>
</configuration>

【讨论】:

【解决方案2】:

好吧,事实证明,我试图运行的集成测试需要将此参数传递给 Tomcat 插件而不是 Failsafe 插件。谢谢你们的帮助!

【讨论】:

  • 我看到了同样的问题,但因为我没有使用 Tomcat,所以无法以这种方式修复它。 Finnaly 我已经通过在 Build 部分中指定来调整我的 Jenkins 工作: clean test -Dsun.net.http.allowRestrictedHeaders=true
猜你喜欢
  • 1970-01-01
  • 2012-02-11
  • 1970-01-01
  • 2011-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-18
  • 2019-05-08
相关资源
最近更新 更多