为了微调在哪些时间以及在哪些环境中运行哪些测试,我们为maven-surefire-plugin设置了几个执行.我们将默认配置设置为跳过所有测试,然后为我们想要的执行启用它们.这本身对我们很有用.
<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>
Run Code Online (Sandbox Code Playgroud)
当我将maven-cobertura-plugin添加到混合中时,我遇到了问题.cobertura目标运行,并成功地完成我的课程.但是,没有测试运行.我假设这是因为cobertura运行的测试执行是跳过的.但是,我找不到如何指定为此执行设置的阶段和目标.当我打开所有测试时,输出似乎表明这些仍然在这些单元测试和集成测试阶段/目标中运行.
<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>
Run Code Online (Sandbox Code Playgroud)
我如何指定一个surefire执行,以便cobertura将针对检测类运行它?
您将从文档中注意到cobertura:cobertura
cobertura
在它自己的生命周期(而不是default
生命周期)中运行 test
在运行自身之前调用生命周期阶段因此,相应的接线应该会自动导致仪器和测试。
归档时间: |
|
查看次数: |
13079 次 |
最近记录: |