生成JUnit测试用例的XML报告

时间:2017-01-05 07:50:23

标签: java maven jenkins junit sonarqube

如何生成Maven项目的XML报告输出? 我试图在Sonar中查看测试覆盖率报告,但是从文档

来看它的下降率为0.0%

http://docs.sonarqube.org/display/PLUG/Code+Coverage+by+Unit+Tests+for+Java+Project

我知道我们必须提供JUnit报告的路径。 任何人都可以解释我在pom.xml中要做的条目是什么,以获取XML格式的JUnit报告?

1 个答案:

答案 0 :(得分:1)

由于您正在讨论报道报告,请查看: http://www.eclemma.org/jacoco/trunk/doc/

以下是JaCoCo的Maven配置示例,您可以在target / site / jacoco文件夹中找到覆盖率报告:

        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.8</version>
            <executions>
                <execution>
                    <id>default-prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-report</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-check</id>
                    <goals>
                        <goal>check</goal>
                    </goals>
                    <configuration>
                        <rules>
                            <rule>
                                <element>BUNDLE</element>
                                <limits>
                                    <limit>
                                        <counter>LINE</counter>
                                        <value>COVEREDRATIO</value>
                                        <!-- increase this number to enforce a minimum -->
                                        <minimum>0.0</minimum>
                                    </limit>
                                </limits>
                            </rule>
                        </rules>
                    </configuration>
                </execution>
            </executions>
        </plugin>