maven - Maven 故障安全系统PropertyVariables
问题描述
我systemPropertyVariables
为maven-failsafe-plugin
. 在集成阶段运行集成测试时,systemPropertyVariables
会正确选择。
当我通过我的 IDE (IntelliJ) 运行单个测试时,systemPropertyVariables
它们也会被拾取,但我不希望这样。
有没有办法在不使用 Maven 配置文件的情况下防止这种情况?
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<includes>
<include>**/*End2EndTest.java</include>
</includes>
<systemPropertyVariables>
<tomcat.host>host</tomcat.host>
<tomcat.port>8080</tomcat.port>
<tomcat.context>/</tomcat.context>
<tests.browser.name>chrome</tests.browser.name>
<tests.selenium.grid.address>http://localhost:4444/wd/hub/</tests.selenium.grid.address>
<spring.profiles.active>build</spring.profiles.active>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
提前致谢。问候
解决方案
该configuration
元素位于插件级别,因此它将适用于所有构建。要限制它,请创建一个执行并将配置移入其中。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<!-- this configuration applies to all builds
using this plugin, whether by specific
goal, or phase. -->
<includes>
<include>**/*End2EndTest.java</include>
</includes>
</configuration>
<executions>
<execution>
<!-- this configuration only is used if
the integration-test phase, or later
phase, is executed -->
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<systemPropertyVariables>
<tomcat.host>host</tomcat.host>
<tomcat.port>8080</tomcat.port>
<tomcat.context>/</tomcat.context>
<tests.browser.name>chrome</tests.browser.name>
<tests.selenium.grid.address>http://localhost:4444/wd/hub/</tests.selenium.grid.address>
<spring.profiles.active>build</spring.profiles.active>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
有了这个:
mvn failsafe:integration-test
不会拿起系统属性。mvn integration-test
,mvn verify
,mvn deploy
等将使用它们。- 任何命令都将使用
includes
.
推荐阅读
- html - 如何在输入标签中使用 runat = "server"?
- laravel - Laravel 护照刷新令牌
- java - Jersey 2.27 - 使用 ExceptionMapper 处理错误时不接收 JSON
- angular - 在 Angular 7 单元测试中测试变换
- git - 从现有项目创建一个 git repo,并运行 `git diff`
- android - 应用程序不显示 Android Pie
- flutter - Flutter 动画在第一次渲染时不流畅
- fiware - 关于FIWARE 7.5版本中各个组件的版本
- c# - 如何在后端asp.net mvc中控制图像的大小
- azure - 使用 ODATA 从 Application Insights REST API 获取最旧的记录