简体   繁体   English

如何在maven-cobertura-plugin中运行cobertura测试?

[英]How do I configure when cobertura tests run in maven-cobertura-plugin?

In order to fine-tune which tests are run at which times and in which environments, we have several executions set up for the maven-surefire-plugin. 为了微调在哪些时间以及在哪些环境中运行哪些测试,我们为maven-surefire-plugin设置了几个执行。 We set the default configuration to skip all tests, then enable them for the executions we want. 我们将默认配置设置为跳过所有测试,然后为我们想要的执行启用它们。 This by itself works well for us. 这本身对我们很有用。

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
     <skip>true</skip>
  </configuration>
  <executions>
     <execution>
       <id>unit-tests</id>
       <phase>test</phase>
       <goals>
          <goal>test</goal>
       </goals>
       <configuration>
          <skip>false</skip>
          <includes>
             <include>**/*Tests.java</include>
          </includes>
          <excludes>
             <exclude>**/*IntegrationTests.java</exclude>
          </excludes>
       </configuration>
     <execution>
     <execution>
       <id>integration-tests</id>
       <phase>integration-test</phase>
       <goals>
          <goal>test</goal>
       </goals>
       <configuration>
          <skip>false</skip>
          <includes>
             <include>**/*IntegrationTests.java</include>
          </includes>
       </configuration>
     <execution>
   </executions>
</plugin>

When I add the maven-cobertura-plugin to the mix, I run into problems. 当我将maven-cobertura-plugin添加到混合中时,我遇到了问题。 The cobertura goal runs, and successfully instruments my classes. cobertura目标运行,并成功地完成我的课程。 However, no tests get run. 但是,没有测试运行。 I assume this is because the test execution that cobertura is running in is one that is skipped. 我假设这是因为cobertura运行的测试执行是跳过的。 However, I cannot find how to specify which phase and goal to set up for this execution. 但是,我找不到如何指定为此执行设置的阶段和目标。 When I turn on all tests, the output seems to indicate that these are still running in these unit-tests and integration-tests phases/goals. 当我打开所有测试时,输出似乎表明这些仍然在这些单元测试和集成测试阶段/目标中运行。

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>cobertura-maven-plugin</artifactId>
  <version>2.4</version>
  <configuration>
     <formats>
        <format>xml</format>
        <format>html</format>
     </formats>
  </configuration>
  <executions>
     <execution>
        <phase>package</phase>
        <goals>
           <goal>cobertura</goal>
        </goals>
     </execution>
  </executions>
</plugin>

How do I need to specify a surefire execution so that the cobertura will run it against the instrumented classes? 我如何指定一个surefire执行,以便cobertura将针对检测类运行它?

You will note from the docs that cobertura:cobertura 您将从文档中注意到cobertura:cobertura

  • Must be wired as a report 必须作为报告连线
  • Instruments, tests and generates a report 仪器,测试和生成报告
  • Runs in its own lifecycle cobertura (not the default lifecycle) 在自己的生命周期中运行cobertura (不是default生命周期)
  • Invokes lifecycle phase test before running itself 在运行之前调用生命周期阶段test

So, wiring it accordingly should automatically result in instrumentation and testing. 因此,相应地连接它应该自动导致仪器和测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何配置Maven-cobertura-plugin来检测依赖项jar - How do I configure maven-cobertura-plugin to instrument a dependency jar 常春藤无法解决Maven-cobertura-plugin - Ivy cannot resolve maven-cobertura-plugin Maven找不到maven-plugins:maven-cobertura-plugin - Maven failure to find maven-plugins:maven-cobertura-plugin 使用cobertura maven插件时,如何设置cobertura数据文件的位置? - How can I set the location for the cobertura data file when using the cobertura maven plugin? 我如何让 mvn cobertura:cobertura 不运行比 mvn test 更多的测试 - how do I make mvn cobertura:cobertura not run more tests than mvn test 使用cobertura和maven网站插件时,测试运行两次 - Tests running twice when using cobertura and maven site plugin 当Maven与Cobertura报告一起运行并安装目标时,Cobertura检查失败 - Cobertura check fails when maven run with Cobertura report and install goals 我如何在使用Maven为Linux上的Jenkins编译cobertura-plugin时解决丢失的工件 - How do i resolve missing artifact while using maven to compile cobertura-plugin for Jenkins on linux 我如何正确整合Maven,Jenkins,Sonar和Cobertura? - How do I correctly integrate Maven, Jenkins, Sonar and Cobertura? 当Maven父pom启用时,如何在子项目中禁用Cobertura? - How do I disable Cobertura in a child project when it is enabled by a Maven parent pom?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM