You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过pom.xml配置Maven profile指定Cucumber运行器并生成聚合报告

问题1解答:POM Profile绑定指定Cucumber运行器

仅需两步配置即可实现需求:

  1. 为每个profile添加对应运行器全类名的属性,修改后的profile配置如下:
<profile>
  <id>local</id>
  <properties>
    <test.runner.class>selenium/runners/CucumberLocalTestRunner.java</test.runner.class>
  </properties>
</profile>
<profile>
  <id>feature_branch</id>
  <properties>
    <test.runner.class>selenium/runners/CucumberFeatureBranchTestRunner.java</test.runner.class>
  </properties>
</profile>
<profile>
  <id>master</id>
  <properties>
    <test.runner.class>selenium/runners/CucumberMasterTestRunner.java</test.runner.class>
  </properties>
</profile>
  1. 在pom.xml的build节点下配置maven-failsafe插件(对应verify生命周期执行逻辑),引用上述配置的属性:
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-failsafe-plugin</artifactId>
      <version>2.22.2</version>
      <configuration>
        <includes>
          <include>${test.runner.class}</include>
        </includes>
      </configuration>
      <executions>
        <execution>
          <goals>
            <goal>integration-test</goal>
            <goal>verify</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

配置完成后执行mvn clean verify -P local就只会运行CucumberLocalTestRunner类对应的用例。

问题2解答:失败用例重跑聚合报告的推测验证

你的推测完全正确。
你使用的ExtendedCucumber扩展天生支持失败用例自动重试+结果聚合能力:

  • 你配置的retryCount = 2代表失败用例会自动重试2次,不需要手动二次执行
  • 你配置的detailedAggregatedReport = true会自动聚合所有重试的用例结果,只要任意一次重试执行通过,最终报告就会标记该用例为通过状态
  • 注意事项:建议你把@ExtendedCucumberOptions中的jsonReport路径和@CucumberOptions中plugin配置的json报告路径统一,避免聚合报告读取原始结果失败。

内容的提问来源于stack exchange,提问作者asinha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 16:15:03