I love to develop test driven, but even more I love code analysis tools that show me what to improve. Sonar is quite “popular” and common for Java developers and I’m using it already for years in different projects.
If you want to see integration test coverage, you have to set the jacoco maven plugin together with the fail safe plugin in your maven config (pom.xml):
<build> <plugins> <!-- integration tests --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <executions> <execution> <goals> <goal>integration-test</goal> </goals> </execution> </executions> </plugin> <!-- for integration test coverage in sonar --> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <executions> <execution> <id>jacoco-initialize</id> <goals> <goal>prepare-agent-integration</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <properties> <!-- needs to be set for jacoco's forked process --> <argLine>${env.MAVEN_OPTS}</argLine> </properties>
argLine
is used as additional param in the javaagent command line section jacoco uses (needs to be set, otherwise the maven opts are not set for the forked process – OutOfMemoryException and so on…). See jacoco’s documentation for details.
The result in Sonar is pretty amazing: