java - 使用 Maven 插件生成 Cobertura 报告

标签 java code-coverage cobertura maven-cobertura-plugin

我对代码和 war 文件进行了检测,成功部署到 tomcat 容器中。

我正在对其运行客户端测试。成功运行测试后,当我关闭 tomcat 实例时,tomcat 的 bin 目录中会出现 Cobertura.ser 文件。

Cobertura.ser 文件包含代码覆盖文件的所有详细信息。

现在,我想配置一个 Maven 任务来从 .ser 文件生成 Cobertura html 报告。

我阅读了 Cobertura-maven-plugin 的帮助指南,但无法正确理解。

(我没有运行 junit 测试,但正在执行 selenium 测试)。

<plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>cobertura-maven-plugin</artifactId>
                        <version>2.5.2</version>
                        <executions>
                            <execution>
                                <id>instrument-code</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>instrument</goal>
                                </goals>
                                <configuration>
                                    <attach>true</attach>
                                </configuration>
                            </execution>
                            <execution>
                                <id>generate-report</id>
                                <phase>prepare-package</phase>                                
                                <goals>
                                    <goal>cobertura</goal>
                                </goals>
                                <configuration>
                                    <dataFile>C:\Servers\apache-tomcat-8.0.11\bin\cobertura.ser</dataFile>
                                    <formats>
                                        <format>html</format>
                                        <format>xml</format>
                                    </formats>
                                    <outputDirectory>C:\Users\satyam\report</outputDirectory> 
                                </configuration>
                            </execution>
                        </executions>                        
                    </plugin>

这是我的 Cobertura-plugin 的 Maven 配置,但这样 Maven 就不会从位于 tomcat bin 目录中的 Cobertura.ser 文件生成报告。

最佳答案

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
 <formats>
   <format>html</format>
   <!-- format>xml</format -->
 </formats>
 </configuration>
 </plugin>

关于java - 使用 Maven 插件生成 Cobertura 报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26228571/

相关文章:

java - 将字符串从 thymeleaf 传递到 Controller

java - 无法为 Android Google map 创建 ClusterManager

.net-core - .Net Core 2.0 中的代码覆盖率

java - 从 jar 执行中获取 Java 覆盖率

grails - Grails Cobertura findAllBy

Scala、sbt 和 emma 或 Cobertura

java - 如何在不使用标签的情况下打破嵌套循环

java - 如何在FragmentList中实现onItemClick方法?

java - 使用 Junit 4 进行 java servlet 的 Happy Flow 测试用例

maven-3 - 代码覆盖率 : Cobertura and SonarQube 5. 3 Maven 集成