java - Get correct coverage in sonar for unit and integration tests in separate maven modules -
my project setup simple (all source available @ github):
parent
↳ backend
↳ client
↳ integration-tests
and after runing maven:
mci sonar:sonar -dsonar.host.url=http://localhost:9000 -dsonar.login=12...9 i see unit , integration tests visible sonar, coverage not.

for intelij idea jacoco-it.exec looks fine: 
i'm assuming culprit here:
[info] sensor jacocosensor [java] [info] no jacoco analysis of project coverage can done since there no class files. [info] sensor jacocosensor [java] (done) | time=1ms so did small hack (in short: copied source files integration-test module):
<properties> <sonar.sources>${basedir}/target/copied</sonar.sources> </properties> [...] <!-- hack generate coverage reports --> <plugin> <artifactid>maven-resources-plugin</artifactid> <version>${maven-resources-plugin.version}</version> <executions> <execution> <id>copy-resources</id> <phase>generate-sources</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputdirectory>${sonar.sources}</outputdirectory> <resources> <resource> <directory>${basedir}/../backend/src/main/java</directory> <filtering>false</filtering> </resource> </resources> </configuration> </execution> </executions> </plugin> <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>build-helper-maven-plugin</artifactid> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>${sonar.sources}</source> </sources> </configuration> </execution> </executions> </plugin> but classes ale duplicated (sonar shows classes ../target/copied dir): 
sonar version: 6.5
jacoco maven plugin: 0.7.5.201505241946 (also tried lastest 0.7.9)
any ideas should here?
looks have answer question:
report wasn't generated because
post-unit-testexecution in rong phase, instead of<phase>test</phase>have<phase>verify</phase>i had wrong goal
post-integration-test. , change<goal>report-integration</goal><goal>report-aggregate</goal>added properties:
<jacoco.itreportpath>${project.basedir}/../integrations-tests/target/jacoco-it.exec</jacoco.itreportpath>,<sonar.jacoco.reportpaths>${jacoco.itreportpath},${project.build.directory}/jacoco-it.exec,${project.build.directory}/jacoco.exec</sonar.jacoco.reportpaths>
all chages , update project available on github
Comments
Post a Comment