运行多个 Maven 配置文件 + Cucumber JVM



由于Cucumber JVM不支持Profiles,我尝试使用Maven。 我想做的是根据其标签激活某个测试子集,并将其指向正确的环境。

这是我的功能文件:

Feature: Validate data
@dev
Scenario: Dev environment
Given dev data
@qa
Scenario: Test environment
Given test data

这是我的绒球.xml:

...
<profiles>
<profile>
<id>dev</id>
<properties>
<cucumber.options>
--tags @dev
</cucumber.options>
<base.url>http://dev.base.url.to.application</base.url>
</properties>
</profile>
<profile>
<id>qa</id>
<properties>
<cucumber.options>
--tags @qa
</cucumber.options>
<base.url>http://qa.base.url.to.application</base.url>
</properties>
</profile>
<profile>
<id>firefox</id>
<properties>
<driver.class>org.openqa.selenium.firefox.FirefoxDriver</driver.class>
</properties>
</profile>
<profile>
<id>chrome</id>
<properties>
<driver.class>org.openqa.selenium.chrome.ChromeDriver</driver.class>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<cucumber.options>${cucumber.options}</cucumber.options>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>

当我尝试一次运行多个配置文件时,即使用以下命令:

mvn test -P dev,qa

我的测试只有一个被执行。 如果我在没有配置文件的情况下运行它,则两个测试都会被执行(特别是 qa 配置文件(。 我的配置文件配置不正确吗? 还是我的标签有问题?

dev配置文件中,将cucumber.options属性设置为--tags @dev。在qa配置文件中,将cucumber.options属性设置为--tags @qa。因此,将这些配置文件与-P dev,qa组合时,qa配置文件将覆盖开发配置文件设置的cucucumber.options值。

而且因为这是一个单一元素combine.children=merge所以不起作用,也没有好方法来合并这些配置文件。

最新更新