声纳中未显示整合覆盖率结果

时间:2015-05-13 13:22:24

标签: maven jenkins sonarqube jacoco surefire

我正在尝试在我的声纳实例中获取集成测试统计信息。经过大量的搜索,我仍然没有发现我做错了什么。我使用配置文件跳过(IT)测试,这似乎对我有用。

在詹金斯,我的声纳构建目标是

verify -P integration-test -Dsonar.phase=verify

以及我之前的集成测试构建

failsafe:integration-test -P integration-test

我有以下pom.xml

<build>
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
            <execution>
                <goals>
                    <goal>analyze</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <skipTests>${skipUnitTests}</skipTests>
        </configuration>
    </plugin>
    <!-- Run integration tests (*IT) -->
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <executions>
            <execution>
                <id>integration-test</id>
                <goals>
                    <goal>integration-test</goal>
                    <goal>verify</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <skipTests>${skipITTests}</skipTests>
            <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
            <argLine>${jacoco.agent.argLine}</argLine>
        </configuration>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
    </plugin>
    <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <executions>
            <execution>
                <id>jacoco-initialize</id>
                <goals>
                    <goal>prepare-agent</goal>
                </goals>
                <configuration>
                        <destfile>${project.build.directory}/jacoco.it.exec</destfile>
                    <datafile>${project.build.directory}/jacoco.it.exec</datafile>
                </configuration>
            </execution>
            <execution>
                <id>jacoco-site</id>
                <phase>package</phase>
                <goals>
                    <goal>report</goal>
                </goals>
                <configuration>
                    <destfile>${project.build.directory}/jacoco.it.exec</destfile>
                        <datafile>${project.build.directory}/jacoco.it.exec</datafile>
                </configuration>
            </execution>
            <execution>
                <id>pre-integration-test</id>
                <phase>pre-integration-test</phase>
                <goals>
                    <goal>prepare-agent-integration</goal>
                </goals>
                <configuration>
                    <destfile>${project.build.directory}/jacoco.it.exec</destfile>
                        <datafile>${project.build.directory}/jacoco.it.exec</datafile>
                </configuration>
            </execution>
            <execution>
                <id>post-integration-test</id>
                <phase>post-integration-test</phase>
                <goals>
                    <goal>report-integration</goal>
                </goals>
                <configuration>
                    <destfile>${project.build.directory}/jacoco.it.exec</destfile>
                        <datafile>${project.build.directory}/jacoco.it.exec</datafile>
                </configuration>
            </execution>
        </executions>
    </plugin>
</build>
<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>${maven-surefire-report-plugin.version}</version>
        </plugin>
    </plugins>
</reporting>
<profiles>
    <profile>
        <id>test</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <properties>
            <maven.test.skip>false</maven.test.skip>
            <skipUnitTests>false</skipUnitTests>
            <skipITTests>true</skipITTests>
            <maven.test.failure.ignore>false</maven.test.failure.ignore>
        </properties>
    </profile>
    <profile>
        <id>integration-test</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <properties>
            <maven.test.skip>false</maven.test.skip>
            <skipUnitTests>true</skipUnitTests>
            <skipITTests>false</skipITTests>
            <maven.test.failure.ignore>false</maven.test.failure.ignore>
        </properties>
    </profile>
    <profile>
        <id>sonar</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <properties>
            <maven.test.skip>false</maven.test.skip>
            <skipUnitTests>true</skipUnitTests>
            <skipITTests>false</skipITTests>
            <maven.test.failure.ignore>true</maven.test.failure.ignore>

            <sonar.jdbc.url>jdbc:mysql://sonar-url/sonar?useUnicode=true&amp;characterEncoding=utf8</sonar.jdbc.url>
            <sonar.jdbc.driverClassName>com.mysql.jdbc.Driver</sonar.jdbc.driverClassName>
            <sonar.jdbc.username>sonar</sonar.jdbc.username>
            <sonar.jdbc.password>sonar</sonar.jdbc.password>
            <sonar.host.url>http://sonar-url/</sonar.host.url>
            <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
            <sonar.junit.reportsPath>target/surefire-reports</sonar.junit.reportsPath>
            <sonar.jacoco.reportPath>target/jacoco.exec</sonar.jacoco.reportPath>
            <sonar.jacoco.itReportPath>target/jacoco.it.exec</sonar.jacoco.itReportPath>
            <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>

            <!-- Sonar exclusions **/static/libs/*.js: third-party JavaScript libraries -->
            <!-- **/jquery*.js: third-party jQuery libraries -->
            <!-- src/main/webapp/static/styles/css/bootstrap/bootstrap*.css src/main/webapp/static/styles/css/bootstrap*.css 
                default Bootstrap CSS files -->
            <!-- (regular & minified) src/main/webapp/static/app/services/ogmSvc.js: angular service lib -->
            <sonar.exclusions>**/static/libs/*.js, **/jquery*.js,
                src/main/webapp/static/styles/css/bootstrap/bootstrap*.css,
                src/main/webapp/static/styles/css/bootstrap*.css,
                src/main/webapp/static/app/services/ogmSvc.js
            </sonar.exclusions>
        </properties>
    </profile>

有谁能告诉我我做错了什么或遗忘了什么?

由于

2 个答案:

答案 0 :(得分:0)

可能您已经完成了这项工作,但不要忘记在声纳服务器中添加集成测试小部件。 (默认登录名为admin-admin)

答案 1 :(得分:0)

问题在于我配置了jacoco错误,因此报告的位置与声纳从中拾取报告的位置不同。