4

I have SonarQube 4.4 installed on my machine. I am trying to generate metrics for a grails (2.4.3) project that has tests written in Spock framework. However, sonar does not show unit tests results or unit tests coverage.

I verified that cobertura coverage.xml gets generated in the path provided below

target/test-reports/cobertura/coverage.xml

And I have

sonar.groovy.cobertura.reportPath

property in my pom.xml mapped to the above path.

Running

mvn sonar:sonar (maven version 3.2.3)

on this project completes successfully and the console log shows the coverage.xml being parsed.

However when I view the project in sonar, I only see the static code analysis metrics but no unit tests or unit tests coverage.

I also tried to run the analysis using sonar-runner and get the same result.

I tried sonar-groovy-plugin (versions: 0.5, 0.6, and 1.0.1) and sonar-cobertura-plugin-1.6.3

Here is the pom.xml build section to run the groovy spock tests

<plugin>
<groupId>org.grails</groupId>
<artifactId>grails-maven-plugin</artifactId>
<version>2.4.3</version>
<configuration>
    <grailsVersion>${grails.version}</grailsVersion>
    <fork>false</fork>
</configuration>
<extensions>true</extensions>
<executions>
    <execution>
        <id>grails-tests</id>
        <phase>test</phase>
        <goals>
            <goal>exec</goal>
        </goals>
        <configuration>
            <command>test-app</command>
            <args>--unit:spock</args>
        </configuration>
    </execution>
</executions>
</plugin>

Anyone used a similar configuration and able to generate code coverage metrics using sonarqube and cobertura?

4

1 に答える 1

7

同様の問題に直面している他の人にとって、ここに解決策があります。カバレッジを表示するには、pom.xml で「sonar.sources」プロパティを設定する必要があることがわかりました。これがサンプルです(個々のディレクトリを指定する必要があります)

<sonar.sources>src/java,src/groovy,grails-app/services,grails-app/controllers,grails-app/domain,grails-app/jobs</sonar.sources>
于 2014-09-17T23:15:53.343 に答える