Maven SonarQube 4.1+;Teamcity-单元测试覆盖率0.0%,单元测试成功率100.0%

Maven SonarQube 4.1+;Teamcity-单元测试覆盖率0.0%,单元测试成功率100.0%,maven,sonarqube,Maven,Sonarqube,我们在Teamcity构建目录中使用maven sonar插件来分析java构建。 除了单元测试覆盖率之外,其他一切看起来都很好 仪表板显示单元测试的覆盖率为0%,成功率为100% 有什么建议吗 SonarQube 4.1如果您使用的是maven,则应在sonar任务之前运行mvn clean install mvn清洁安装声纳:声纳 在pom.xml中添加以下配置: <properties> <sonar.jacoco.reportPath>${project.

我们在Teamcity构建目录中使用maven sonar插件来分析java构建。 除了单元测试覆盖率之外,其他一切看起来都很好

仪表板显示单元测试的覆盖率为0%,成功率为100%

有什么建议吗


SonarQube 4.1

如果您使用的是maven,则应在sonar任务之前运行mvn clean install

mvn清洁安装声纳:声纳

在pom.xml中添加以下配置:

<properties>
    <sonar.jacoco.reportPath>${project.build.directory}/coverage-reports/jacoco-ut.exec</sonar.jacoco.reportPath>
</properties>

<build>
    <plugins>                                   
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <argLine>${surefireArgLine}</argLine>
                <excludes>
                    <exclude>**/*IT.java</exclude>
                </excludes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.6.0.201210061924</version>
            <executions>
                <execution>
                    <id>pre-unit-test</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                    <configuration>
                        <destFile>${sonar.jacoco.reportPath}</destFile>
                        <propertyName>surefireArgLine</propertyName>
                    </configuration>
                </execution>
                <execution>
                    <id>post-unit-test</id>
                    <phase>test</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                    <configuration>
                        <dataFile>${sonar.jacoco.reportPath}</dataFile>
                        <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                    </configuration>
                </execution>
                <execution>
                    <id>pre-integration-test</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                    <configuration>
                        <destFile>${sonar.jacoco.itReportPath}</destFile>
                        <propertyName>failsafeArgLine</propertyName>
                    </configuration>
                </execution>
                <execution>
                    <id>post-integration-test</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                    <configuration>
                        <dataFile>${sonar.jacoco.itReportPath}</dataFile>
                        <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.6.0.201210061924</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

${project.build.directory}/coverage reports/jacoco-ut.exec
org.apache.maven.plugins
maven surefire插件
${surefireArgLine}
**/*IT.java
org.jacoco
jacocomaven插件
0.6.0.201210061924
单元前测试
配制剂
${sonar.jacoco.reportPath}
surefireArgLine
单元后测试
测试
报告
${sonar.jacoco.reportPath}
${project.reporting.outputDirectory}/jacoco-ut
预集成测试
预集成测试
配制剂
${sonar.jacoco.itReportPath}
故障保护argline
整合后测试
整合后测试
报告
${sonar.jacoco.itReportPath}
${project.reporting.outputDirectory}/jacoco-it
org.jacoco
jacocomaven插件
0.6.0.201210061924

Step1。Teamcity项目1运行maven构建,该构建负责mvn清洁安装并执行junits。junits在此构建步骤中运行,TEST.xml报告在步骤2中生成。Teamcity项目1触发另一个脚本项目2。。它执行mvn声纳:声纳。。。它正确读取单元测试通过率并显示在仪表板上。。。但是,单元测试覆盖率信息未被读取,显示为0%I已编辑我的答案。。。你能试试这个配置并告诉我结果吗?在Gradle版本中运行sonar runner时也会发生同样的情况。