[英]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
cobertura
(not the default
lifecycle) 在自己的生命周期中运行cobertura
(不是default
生命周期) test
before running itself 在运行之前调用生命周期阶段test
So, wiring it accordingly should automatically result in instrumentation and testing. 因此,相应地连接它应该自动导致仪器和测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.