我有一个包含4个模块的Maven项目 - 其中3个包含代码和一些测试(测试等于和类的哈希码),而第4个模块用于测试其他3个模块.
现在我想运行cobertura代码覆盖率工具来概述哪些类经过了充分测试,哪些不是.我对该主题进行了一些调查,如果测试的某些源位于其他模块中,则cobertura似乎不知道生成正确的代码覆盖百分比和线路覆盖率.
我已经阅读了一些链接,如SeamTestCoverageWithCobertura和在多模块Maven 2中使用插件Coverage,但必须有一个开箱即用的解决方案.有人可以报告一些关于这个主题的新方向吗?还是有像cobertura这样的工具?我偶然发现了艾玛,但这个工具不提供线路覆盖......
阅读本文后: 使用Cobertura与Maven 3.0.2的正确方法是什么 :http: //www.wakaleo.com/blog/292-site-generation-in-maven-3
我的POM文件如下所示:
<build>
<plugins>
.....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.1</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.6</version>
<configuration>
<skip>true</skip>
<useFile>false</useFile>
<argLine>-Xmx512m</argLine>
<systemProperties>
<property>
<name>generateReport</name>
<value>html</value>
</property>
</systemProperties>
</configuration>
<executions>
<execution>
<id>unit-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<includes>
<include>**/UnitTest*.java</include>
<include>**/*UnitTest.java</include>
<include>**/*Scenarios.java</include>
</includes>
</configuration>
</execution>
<execution>
<id>integration-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${integrationTestsSkip}</skip>
<includes>
<include>**/*IntegrationTest.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用cobertura在Jetty上运行我的webapp时获得覆盖率报告.我们已经使用surefire插件运行cobertura进行单元测试.我们还配置了failafe插件来运行我们的集成测试.
我已经(手动)检测了我的战争并进行了部署.
当mvn verify使用集成测试仅运行配置文件时,似乎cobertura正在工作,因为我在eclipse控制台中获得了所有类型的新警告(我从那里运行jetty)可能是因为字节代码被cobertura更改了.但.ser即使在调用"stop"jetty服务器时,我也没有写入文件.
我.ser在运行时得到一个文件,mvn cobertura:cobertura并在target/site我的webapp目录下生成一个报告.该报告显示0%的覆盖率,因为cobertura:cobertura没有运行任何测试.
如何使用failsafe make cobertura运行我的集成测试?还有其他建议吗?
谢谢,本