我如何配置在maven-cobertura-plugin中运行cobertura测试? [英] How do I configure when cobertura tests run in maven-cobertura-plugin?

查看:87
本文介绍了我如何配置在maven-cobertura-plugin中运行cobertura测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了微调哪些测试在什么时间和环境下运行,我们为maven-surefire-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. 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>

当我将maven-cobertura-plugin添加到混合中时,我遇到了问题. cobertura目标得以实现,并成功地为我的课程进行了辅导.但是,没有运行测试.我认为这是因为cobertura正在运行的测试执行被跳过了.但是,我找不到如何指定要为此执行设置的阶段和目标.当我打开所有测试时,输出似乎表明这些测试仍在这些单元测试和集成测试阶段/目标中运行.

When I add the maven-cobertura-plugin to the mix, I run into problems. The cobertura goal runs, and successfully instruments my classes. However, no tests get run. I assume this is because the test execution that cobertura is running in is one that is skipped. 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>

我需要如何指定一个surefire执行,以便cobertura可以对检测到的类运行它?

How do I need to specify a surefire execution so that the cobertura will run it against the instrumented classes?

推荐答案

您将

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

    因此,对其进行相应的布线应自动进行检测和测试.

    So, wiring it accordingly should automatically result in instrumentation and testing.

    这篇关于我如何配置在maven-cobertura-plugin中运行cobertura测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆