i've inherited odd maven multi module project. standard business classes , unit tests in module called 'code' , we've nice simple working sonar metrics module. second module holds various integration style tests run against deployed glassfish server, these run unit test in integ-test module.
pom.xml // root level, code // business code , unit tests :-) modulea moduleb integ-test // ;-( modulea moduleb i know simplest option move 'integ-test' classes 'code' module , refactor them real integration tests moment isn't option.
i've figured out way record level of code coverage 'integ-tests' module using jacoco:dump goal download jacococ.exec integ-test modules.
my maven pom structure looks this
pom.xml // defined jacoco verify -> report goal code // business code , unit test modulea target/jacoco.exec - unit test coverage pom.xml pom.xml - defines standard jacoco prepare-agent goal integ-test // modulea target/jacoco.exec - integration test coverage pom.xml pom.xml- defines jacoco dump , merge my current approach merge jacococ.exec files in 'integ-test' module , use 'destfile' value save these details 'code' module jacoco-it.exec file. standard sonar:sonar goal should pick file , use integration test coverage.
pom.xml integ-test modulea target/jacoco.exec - integration test coverage moda moduleb target/jacoco.exec - integration test coverage modb code modulea moduleb target/jacoco-it.exec - should merged content of 2 files above pom.xml my root level pom.xml defines jacoco-maven-plugin config
<plugin> <groupid>org.jacoco</groupid> <artifactid>jacoco-maven-plugin</artifactid> <configuration> <append>true</append> <includes> <include>com/a/b/c/**</include> </includes> </configuration> <executions> <execution> <id>jacoco-agent</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>jacoco-dump</id> <phase>pre-integration-test</phase> <goals> <goal>dump</goal> </goals> </execution> <execution> <id>jacoco-merge</id> <phase>post-integration-test</phase> <goals> <goal>merge</goal> </goals> <configuration> <filesets> <fileset implementation="org.apache.maven.shared.model.fileset.fileset"> <directory>${project.basedir}/integ-test</directory> <includes> <include>*.exec</include> </includes> </fileset> </filesets> <destfile>${sonar.jacoco.itreportpath}</destfile> </configuration> </execution> <execution> <id>jacoco-site</id> <phase>verify</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin> <sonar.jacoco.itreportpath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itreportpath> i've linked jacoco:merge goal maven post-integration-test phase ensure merge happens after tests run, 'jacoco-it.exec' file created within 'integ-test' folder.
any suggestions?
what pointing destfile in target directory of master pom? define
<configuration> <append>true</append> <destfile>${project.basedir}/../target/jacoco-it.exec</destfile> <propertyname>jacoco.integrationtest.arguments</propertyname> </configuration> in sub-projects. coverage data appended in jacoco-it.exec file. file picked sonarqube , see coverage coverage. can use jacoco.exec file name well.
Comments
Post a Comment