Sonar/Jacoco : Per Test coverage - need help

Must-share information (formatted with Markdown):

  • which versions are you using
    sonarqube-8.6.0.39681 server to display Jacoco pertest coverage

  • what are you trying to achieve
    Need to enable per test coverage for unit tests through jacoco for my junit tests

  • what have you tried so far to achieve this
    I have created a Springboot project with some unit test to measure the per test coverage. I can see on the test coverage, but I can not get the jacoco per test coverage which actually give the link between the application code lines and the unit tests.

pom set up:

<java.version>1.8</java.version>
<sonar.language>java</sonar.language>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.coverage.jacoco.xmlReportPaths>{project.build.directory}/target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths> <sonar.jacoco.reportsPaths>{project.build.directory}/target/jacoco.exec</sonar.jacoco.reportsPaths>
<sonar.tests>src/test/java</sonar.tests>
<sonar.projectKey>sonar-test</sonar.projectKey>
<sonar.host.url>http://localhost:9000</sonar.host.url>
<sonar.login>admin</sonar.login>
<sonar.password>admin123</sonar.password>

coverage-per-test org.apache.maven.plugins maven-surefire-plugin 2.22.2 **/*Test.java **/*Tests.java listener org.sonar.java.jacoco.JUnitListener
			<plugin>
					<groupId>org.jacoco</groupId>
					<artifactId>jacoco-maven-plugin</artifactId>
					<version>0.8.5</version>
					<executions>
						<execution>
							<id>default-prepare-agent</id>
							<goals>
								<goal>prepare-agent</goal>
							</goals>
						</execution>
						<execution>
							<id>default-report</id>
							<phase>prepare-package</phase>
							<goals>
								<goal>report</goal>
							</goals>
						</execution>
					</executions>
				</plugin>
			</plugins>
		</build>
		<dependencies>
			<dependency>
				<groupId>org.sonarsource.scanner.maven</groupId>
				<artifactId>sonar-maven-plugin</artifactId>
				<version>3.8.0.2131</version>
			</dependency>
		</dependencies>
	</profile>
</profiles>

This the expected out come I need to have : https://docs.sonarqube.org/display/SONARQUBE51/Component+coverage
What I need to have is the link inbetween :slight_smile:
image

But now I see just the test coverage:

Hey @Malindu,

Unfortunately for you, this feature has been dropped from SonarQube a long time ago. I’m not sure if this change was even already part of SQ LTS 6.7 (November 2017), but I can tell you that the current SQ LTS 7.9 (July 2019) is clearly and officially not supporting this anymore.

So, to answer this question, this is not possible anymore to have such links when looking at coverage results. There is simply not such option anymore.

I hope this clarifies the situation for you,

Michael

Thanks for the confirmation regarding this.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.