【转】maven同时使用maven-surefire-report-plugin和maven-surefire-plugin默认将执行两次test...

本文介绍如何通过配置maven-surefire-report-plugin来避免重复执行测试,提高构建效率。通过将目标设置为report-only,可以指定插件仅生成报告而不重新运行测试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

https://issues.apache.org/jira/browse/SUREFIRE-753

Here the pom.xml snippet how i configured the report-plugin:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>2.9</version>
        <configuration>
          <outputName>failsafe-report</outputName>
          <reportsDirectories>
            <reportsDirectory>${project.build.directory}/failsafe-reports</reportsDirectory>
          </reportsDirectories>
        </configuration>
        <reportSets>
          <reportSet>
            <reports>
              <report>report-only</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>

This means the name of the link in the navigation must be changed as well. May be it's needed to have a supplemental configuration parameter for this or the outputName could be used instead.

 

maven-surefire-plugin是maven默认的test执行器。而maven-surefire-report-plugin是site生成test报表的一个插件。maven-surefire-report-plugin默认目标是report,这个将告诉maven执行test,然后搜集surefire-reports下xml生成报告。 而默认mvn site也会执行一次test。所以造成执行两次,解决办法:

< plugin >
  < groupId >org.apache.maven.plugins< /groupId >
  < artifactId >maven-surefire-report-plugin< /artifactId >
  < version >2.7< /version >
  < reportSets >
    < reportSet >
    < reports >
      < report >report-only< /report >
    < /reports >
    < /reportSet >
  < /reportSets >
< /plugin >

将其目标更改report-only,则告诉报表插件,自己不用执行test了,直接使用生命周期里test的执行 surefire-reports结果。bug新颁布已经解决了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值