【问题标题】:Maven failsafe systemPropertyVariablesMaven 故障安全系统PropertyVariables
【发布时间】:2019-05-15 14:02:58
【问题描述】:

我为maven-failsafe-plugin 定义了一些systemPropertyVariables。 在集成阶段运行集成测试时,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>

提前致谢。 问候

【问题讨论】:

    标签: maven intellij-idea maven-failsafe-plugin


    【解决方案1】:

    configuration 元素位于 plugin 级别,因此它将适用于所有构建。要限制它,请创建一个执行并将配置移入其中。

    <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-testmvn verifymvn deploy使用它们。
    • 任何命令都将使用includes

    【讨论】:

      猜你喜欢
      • 2012-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-15
      • 1970-01-01
      • 1970-01-01
      • 2020-10-17
      • 1970-01-01
      相关资源
      最近更新 更多