如何通过mvn通过pom.xml运行包含多个黄瓜运行器类



我有几个跑步者类说黄瓜localtestrrunner,黄瓜featurebranchtestrrunner,黄瓜mastertestrrunner类。这些跑步者类使用扩展的黄瓜选项。我使用的是cucumber jvm版本4.4.0。

在pom文件中,我设置了与runner类有一对一关系的配置文件。

我将如何在pom文件中包含运行程序类,以便如果我运行mvn clean verify -P local,那么只有黄瓜localtestrunner会运行。

其次,我猜测扩展数字选项将在重新运行失败的测试后生成合并报告。(即我有三个测试。第一次运行:两次通过,一次失败。第二次运行:-只有失败的运行并通过。然后我将看到一份全部通过的报告。

<profile>
<id>local</id>
<properties>

</properties>
</profile>
<profile>
<id>master</id>
<properties>

</properties>
</profile>
package selenium.runners;
import com.github.mkolisnyk.cucumber.runner.ExtendedCucumber;
import com.github.mkolisnyk.cucumber.runner.ExtendedCucumberOptions;
import cucumber.api.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(ExtendedCucumber.class)
@ExtendedCucumberOptions(
jsonReport = "target/81/cucumber.json",
jsonUsageReport = "target/81/cucumber-usage.json",
usageReport = true,
detailedReport = true,
detailedAggregatedReport = true,
overviewReport = true,
overviewChartsReport = true,
pdfPageSize = "A4 Landscape",
toPDF = true,
outputFolder = "target/81",
retryCount = 2,
threadsCount = 2)
@CucumberOptions(
glue = {"selenium.stepdefs"},
features = {"src/test/resources/features/"},
plugin = {"json:target/cucumber/cucumber.json", "junit:target/cucumber/cucumber.xml"},
strict = true,
tags = "@local")
public class CucumberLocalTestRunner {}

你想在你的插件中添加跑步者类,如下所示:

<profiles>
<profile>
<id>local</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>**/CucumberLocalTestRunner.java</include>
</includes>
<argLine>Xmx12g -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp -Duser.timezone=Europe/London</argLine>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>5.6.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>Local Run</projectName>
<outputDirectory>${project.build.directory}</outputDirectory>
<inputDirectory>${project.build.directory}</inputDirectory>
<jsonFiles>
<param>cucumber.json</param>
</jsonFiles>
<mergeFeaturesById>false</mergeFeaturesById>
<mergeFeaturesWithRetest>false</mergeFeaturesWithRetest>
<checkBuildResult>false</checkBuildResult>
<buildNumber>1</buildNumber>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo message="Cucumber execution complete. Reports are available in ${project.build.directory}/cucumber-html-reports/feature-overview.html"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

然后为每个配置文件重复,选择要与其他配置文件一起运行的插件等。

最新更新