Maven отказоустойчивая системаPropertyVariables - PullRequest
0 голосов
/ 15 мая 2019

Я определил некоторые 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>

Заранее спасибо.Привет

1 Ответ

1 голос
/ 16 мая 2019

Элемент 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-test, mvn verify, mvn deploy и т. Д. будет использовать их.
  • Любая из команд будет использовать includes.
...