How do I get SonarQube to count spock/groovy unit tests? - gradle

I am trying to configure SonarQube to report an accurate count of the unit test cases in my repository, currently it is only showing the java jUnit test cases.
SonarQube reports the java jUnit test count as well as the overall coverage from jacoco which includes both java and groovy coverage.
How do I get SonarQube to recognize the groovy/spock unit tests in the overall count?
SonarQube 7.7 (I see the issue on 7.4 as well)
I am not sure if there is a specific sonar property I need to set in my Gradle configuration or if there is a plugin in SonarQube itself I need to install?
I do see some related answers about installing the Groovy plugin in SonarQube however there is no mention as to which version of SonarQube this is a solution for (I no longer see this plugin as available)

The marketplace had been missing the Groovy plugin for quite some time. A new version has just been released!
Simply installing the plugin that is available on the Marketplace solved this problem.
https://github.com/pmayweg/sonar-groovy

Related

SonarQube Configuration

We had recently implemented SonarQube in our team and we have a dashboard configured
We've been able to see some of the details but the line coverage and code coverage is 0 always
Can you advise what we're missing ? I've checked the configuration and all of it seems to be in place
Assuming the latest SonarQube version, note that, as mentioned in this thread
Version 5.12 of our SonarJava analyzer deprecated use JaCoCo’s binary format (.exec files) to import coverage.
As a replacement, we developed the sonar-jacoco plugin, which imports JaCoCo’s XML coverage report, and this is the preferred option now. I
That page illustrates how to include those reports for a maven or a gradle project. Again, it depends on the nature of your projects.

SonarQube no longer reporting test coverage from jacoco

SonarQube does no longer show test coverage for my project which is analyzed with jacoco. It seems there was an update on SonarQube (I found new rules dates May 19). I assume it also since then that the test coverage gathered with jacoco maven plugin is no longer evaluated. I've seen older questions with a similar issue, but that was 4 years ago:
JaCoCo SonarQube incompatible version 1007
I updated my POM to the latest plugin version 0.8.4 but to no avail. Any ideas where I need to change something so this works again?
I had exactly the same problem. The problem was that they deprecated the jacoco.exec file and now you have to use the XML format.
To use the new format you only have to install the official jacoco plugin in Sonarqube and everything it's going to work again without any more changes.

spock and clover integration

In my project, we are using spock for unit testing. I want to configure spock test cases with clover so that it can generate the coverage report. I have followed steps and configure it in maven. However, I am not able to configure it properly.
Could anyone guide me, to configure clover with spock?
my groovy test cases are in src/test/groovy package.
Thanks,
Jay Patel
Could anyone guide me, to configure Clover with Spock?
What problem exactly do you have? I'm asking, because tests written in Spock are no different from tests written in any other framework. As long as you build these classes with Clover and execute tests, you shall be able to get code coverage reports.
Please also note that Clover introduced a dedicated support for Spock's test iterations in version 3.3.0. So make sure you're using the latest version of Clover. I suggest Atlassian Clover 4.1.2 (the last version released by Atlassian) or OpenClover 4.2.0 (released by community).

SonarQube 4.3 in Java 8 not showing any Issues

I'm running SonarQube 4.3 in Java 8 and it's not showing any numbers in Issues, Technical Debt and not showing any numbers in Blocker, Critical, etc. I've a gradle project with jacoco plugin and gradle sonarRunner runs fine and generates Unit Tests Coverage and Integration Tests Coverage. Also Java plugin is updated to 2.2.1. Thanks.
As you can see on the Requirements page, Java 8 as a runtime is not fully supported yet, so that might explain some issues you encounter.
You should try to use Java 7 to see if the problem comes from the runtime or from some configuration issues.

The Issues Report Plugin does not retrieve metrics

I have a problem when I run the Issues Report Plugin on the multi-module project. I noted that the documentation indicated that the plugin is incompatible with this kind of project.
Nevertheless, I tried to run a sonar-runner dry run on one of the modules using its projectKey and projectName (retrieved from the widget Description). Unfortunately, the plugin has not retrieved metrics previously analyzed for this module. All anomalies are marked as new.
Is there a way to ensure I get the right values?
The dry run mode for SonarQube analyses on multi-module projects suffers from limitations, which are all fixed in the upcoming 3.6.1 version of SonarQube.
See the following ticket: https://jira.codehaus.org/browse/SONAR-4265
And just to be clear: the Issues Report Plugin does not export measures of metrics, it only exports issues.

Resources