SonarQube not picking up Unit Test Coverage

sonarqube not showing code coverage c#
how to get unit test coverage in sonar c#
sonarqube test coverage
not covered by tests sonarqube
sonar.coverage.jacoco.xmlreportpaths example
sonarqube javascript code coverage
unit tests not showing in sonarqube
sonarqube showing 0% code coverage c#

I am having issues with sonar picking up the jacoco analysis report. Jenkins however is able to pick up the report and display the results. My project is a maven build, built by Jenkins. The jacoco report is generated by maven (configured in the pom). Sonar is executed by using the Jenkins plugin.

This is what I see on SonarQube:

This is the report i can see of the project in jenkins.

The maven plugin config:

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.6.4.201312101107</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>
      <execution>
          <id>default-check</id>
          <goals>
              <goal>check</goal>
          </goals>
      </execution>
    </executions>
</plugin>

Jenkins Sonar Plugin config

You were missing a few important sonar properties, Here is a sample from one of my builds:

sonar.jdbc.dialect=mssql
sonar.projectKey=projectname
sonar.projectName=Project Name
sonar.projectVersion=1.0
sonar.sources=src
sonar.language=java
sonar.binaries=build/classes
sonar.tests=junit
sonar.dynamicAnalysis=reuseReports
sonar.junit.reportsPath=build/test-reports
sonar.java.coveragePlugin=jacoco
sonar.jacoco.reportPath=build/test-reports/jacoco.exec

The error in Jenkins console output can be pretty useful for getting code coverage to work.

Project coverage is set to 0% since there is no directories with classes. Indicates that you have not set the Sonar.Binaries property correctly

No information about coverage per test Indicates you have not set the Sonar.Tests property properly

Coverage information was not collected. Perhaps you forget to include debug information into compiled classes? Indicates that the sonar.binaries property was set correctly, but those files were not compiled in debug mode, and they need to be

SonarQube does not show the Code Coverage but shows the , We have some Unit Tests using the MSTest Framework and using the AzureDevOps with a CI environment we run all the unit tests when a build� Path to coverage report in the Generic Test Data format. Apex: sonar.apex.coverage.reportPath: Path to the test-result-codecoverage.json report file generated by the apex:test:run command of the Salesforce CLI. Note, you must have a Salesforce DX project set up and linked to your Org: C / C++ / Objective-C: sonar.cfamily.gcov.reportsPath

Sonarqube not picking up tests, SonarQube 5.4, Jacoco plugin, Gradle, Scanner 2.7 My project structure is as follows: root | | proja | projb | projc | test I'm trying to upload code coverage to Sonar server. When I run sonarqube Sonarqube not picking up tests. You’ll need a code coverage tool to analyze how much of the project’s code is coverage by unit tests. As mentioned, one of the tools is coverage . The coverage tool can be used to generate a SonarQube-compatible XML report, which is then uploaded to SonarQube.

I had the similar issue, 0.0% coverage & no unit tests count on Sonar dashboard with SonarQube 6.7.2: Maven : 3.5.2, Java : 1.8, Jacoco : Worked with 7.0/7.9/8.0, OS : Windows

After a lot of struggle finding for correct solution on maven multi-module project,not like single module project here we need to say to pick jacoco reports from individual modules & merge to one report,So resolved issue with this configuration as my parent pom looks like:

 <properties>
            <!--Sonar -->
            <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
            <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
        <sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
            <sonar.language>java</sonar.language>

        </properties>

        <build>
            <pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <source>1.5</source>
                            <target>1.5</target>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.sonarsource.scanner.maven</groupId>
                        <artifactId>sonar-maven-plugin</artifactId>
                        <version>3.4.0.905</version>
                    </plugin>

                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.7.9</version>
                        <configuration>
                            <destFile>${sonar.jacoco.reportPath}</destFile>
                            <append>true</append>
                        </configuration>
                        <executions>
                            <execution>
                                <id>agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                </plugins>
            </pluginManagement>
        </build>

I've tried few other options like jacoco-aggregate & even creating a sub-module by including that in parent pom but nothing really worked & this is simple. I see in logs <sonar.jacoco.reportPath> is deprecated,but still works as is and seems like auto replaced on execution or can be manually updated to <sonar.jacoco.reportPaths> or latest. Once after doing setup in cmd start with mvn clean install then mvn org.jacoco:jacoco-maven-plugin:prepare-agent install (Check on project's target folder whether jacoco.exec is created) & then do mvn sonar:sonar , this is what I've tried please let me know if some other best possible solution available.Hope this helps!! If not please post your question..

Test Coverage & Execution, This page lists analysis parameters related to test coverage and execution reports. For more SonarSource analyzers do not run your tests or generate reports. They only Note, you must have a Salesforce DX project set up and linked to your Org. C / C++ reportPath, Path to the PHPUnit unit test execution report file. In the Visual Studio Test build task, I have the Code Coverage Enabled checkbox checked , but I still do not get the code coverage details in SonarQube. The Code Coverage does display in the TFS Build side though. This seem to be a bug with SonarQube latest scanner, since I had it working with the earlier versions. Only after upgrading to

Jenkins does not show coverage results as it is a problem of version compatibilities between jenkins jacoco plugin and maven jacoco plugin. On my side I have fixed it by using a more recent version of maven jacoco plugin

<build>
   <pluginManagement>
     <plugins>
       <plugin>
         <groupId>org.jacoco</groupId>
         <artifactId>jacoco-maven-plugin</artifactId>
         <version>0.7.9</version>
       </plugin>
     <plugins>
   <pluginManagement>
<build>

unit test coverage does not showing up on sonarqube dashboard , 18:49:04.614 INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar- scanner.properties 18:49:04.616 INFO: Project root configuration� unit test coverage does not showing up on sonarqube dashboard #990. Closed jithuvijayan1992 opened this issue Jun 8, SonarQube Scanner 3.1.0.1141

I was facing the same problem and the challenge in my case was to configure Jacoco correctly and to configure the right parameters for Sonar. I will briefly explain, how I finally got SonarQube to display the test results and test coverage correctly.

In your project you need the Jacoco plugin in your pom or parent pom (you already got this). Moreover, you need the maven-surefire-plugin, which is used to display test results. All test reports are automatically generated when you run the maven build. The tricky part is to find the right parameters for Sonar. Not all parameters seem to work with regular expressions and you have to use a comma separated list for those (documentation is not really good in my opinion). Here is the list of parameters I have used (I used them from Bamboo, you might omit the "-D" if you use a sonar.properties file):

-Dsonar.branch.target=master (in newer version of SQ I had to remove this, so that master branch is analyzed correctly; I used auto branch checkbox in bamboo instead)
-Dsonar.working.directory=./target/sonar
-Dsonar.java.binaries=**/target/classes
-Dsonar.sources=./service-a/src,./service-b/src,./service-c/src,[..]
-Dsonar.exclusions=**/data/dto/**
-Dsonar.tests=.
-Dsonar.test.inclusions=**/*Test.java [-> all your tests have to end with "Test"]
-Dsonar.junit.reportPaths=./service-a/target/surefire-reports,./service-b/target/surefire-reports,
./service-c/target/surefire-reports,[..]
-Dsonar.jacoco.reportPaths=./service-a/target/jacoco.exec,./service-b/target/jacoco.exec,
./service-c/target/jacoco.exec,[..]
-Dsonar.projectVersion=${bamboo.buildNumber}
-Dsonar.coverage.exclusions=**/src/test/**,**/common/**
-Dsonar.cpd.exclusions=**/*Dto.java,**/*Entity.java,**/common/**

If you are using Lombok in your project, than you also need a lombok.config file to get the correct code coverage. The lombok.config file is located in the root directory of your project with the following content:

config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true

SonarQube: Unit Test Results Not Shown – RichHewlett.com, The Jacoco based test coverage results were being included fine but not the with SonarQube static analysis, the JUnit unit test results were not It turns out that the java code for the tests is required in order analyse the� Ignore Code Coverage. You can prevent some files from being taken into account for code coverage by unit tests. To do so, go to Project Settings > General Settings > Analysis Scope > Code Coverage and set the Coverage Exclusions property. See the Patterns section for more details on the syntax.

How To Measure Code Coverage Using SonarQube and Jacoco , This will generate the test coverage statistics for our Java code. This contains the code coverage information that SonarQube will pick up during it's scan. With SonarQube 8 the jacoco.exec file is no longer compatible, and instead we have to create a report However i get 0% coverage, 100% unit test Note that there is not such a property for NCover because the location of NCover is automatically discovered by Gallio. Letting the SonarQube platform drive the execution of the unit tests and the code coverage tool. This is the default mode. The first step is to tell SonarQube which projects are unit test projects.

Test Result and Code Coverage is not showing in SonarQube , Test Result and Code Coverage is not showing in SonarQube root configuration file: E:\b\vsts\v2\01\_work\1\.sonarqube\out\sonar-project.properties INFO: Sensor C# Unit Tests Coverage Report Import [csharp] Returns � Order tracking � Store locations � Buy online, pick up in store � In-store events. It is possible to feed SonarQube with tests execution and code coverage reports. See Component Viewer on Unit Test File or Quality Flows > Lack of Unit Tests to browse the results in the web interface. Usage. To be reused by SonarQube: The tests execution reports have to comply to the JUnit XML format.

Generate Codecoverage Report with Jacoco and Sonarqube, reportPath> is no longer supported in the latest version of Sonarqube. JaCoCo is a free code coverage library for Java, which has been created by the EclEmma team based on the lessons learned from Check on UserServiceTest and do Unit Test check. this page is about report from out project. Code Coverage by Integration Tests. To get the code coverage by integration tests on your project, you should simply follow the 5 steps below: Attach and configure a JaCoCo agent to the JVM which you will run your integration tests with.

Comments
  • Somewhere in your console output should say, "Code coverage set to 0%...", That information would be useful to debug your issue. Two things come to mind without looking at it though: 1. You should be setting sonar.binaries property and point it to your compiled class files 2. You should set sonar.tests and point it to your uncompiled test files. 3. You should compile in debug mode (you might be already I can't tell)
  • @Cole9350 so the error i see in the output is: Project coverage is set to 0% since there is no directories with classes. I have tried setting sonar.binaries to the root of the classes directory - /target/classes - but this resulted in an error saying they could not be found
  • correction I tried again and set the fully qualified path to the classes and i am now able to see code coverage. However i know see the error when the jacoco sensor runs: No information about coverage per test.
  • Good! You're almost there. The first error was indicating you hadn't set sonar.binaries. Now your error is telling you to set sonar.tests Like I mention in (2)... After that I'm pretty sure sonar will pick up the coverage
  • @Cole9350 : I am also facing the same problem after i upgraded sonar from 4.0 to 4.5.1. Earlier it used to generate code coverage, but after upgrade there is no info on code coverage, When i have gone through the console output , i see thta jacoco.exec files are generated under target folder but Cobertura sensor was listed instead of jacocoSensor for analysing Codecoverage.
  • The settings are not all required (for examle dynamicAnalysis is deprecated). I upvoted this for the binaries property, i've set this wrong.
  • Hi, I have same configuration for Android-Kotlin, build generating successfully and except code coverage everything is on place. Any suggestion what could be miss. FYI: I'm using exact same config you mentioned.
  • This suggestion helped me for Sonarqube on OpenShift cluster