Christian
Christian

Reputation: 83

Run Cobertura on xtext-project together with Maven and Tycho-surefire

I have a multi-modul project with one test modul that tests three others. I have already set up the cobertura instrumentation, merging and reporting with maven antrun-plugin described here: cobertura on maven multi module project but I don't override the normal classes with the instrumented ones but store them in a instrumented-classes folder in every modul. In the post-integration-test phase I merge the cobertura.ser files and generate a report in the pom.xml of the test modul which is executed last.

How can I configure tycho-surefire to use the instrumented classes instead of the normal? Otherwise I get always 0% coverage...

I didn't find an easy solution, the cobertura:aggregate goal doesn't work

Upvotes: 1

Views: 230

Answers (1)

Christian
Christian

Reputation: 83

I used Jacoco instead, that worked for me.

<!-- This profile is used to gather code coverage with Jacoco -->
    <profile>
        <id>codeCoverage</id>
        <properties>
            <!-- Properties to enable jacoco code coverage analysis -->
            <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
            <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
            <sonar.jacoco.reportPath>/path/to/jacoco.exec</sonar.jacoco.reportPath>
        </properties>

        <build>
            <plugins>
                <!-- Enabling use of jacoco -->
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacoco-plugin-version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                            <configuration>
                                <!-- Where to put jacoco coverage report -->
                                <destFile>${sonar.jacoco.reportPath}</destFile>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>

Upvotes: 1

Related Questions