Uploading Spock/Groovy test results into Sonarqube - gradle

There was a known issue from 2014 that UnitTests written in Groovy cannot have their PASS/FAIL metrics uploaded into SonarQube.
http://sonarqube-archive.15.x6.nabble.com/Resource-not-found-for-Groovy-unit-tests-td5024669.html
Does anyone know if this issue is fixed? I am still have the issue with Sonar 6.1 using Spock unit tests and Gradle build system.
Any clue on the correct gradle sonar settings to make this happen?

The solution for us was to install the Groovy plugin in Sonarqube 6.1.
Once the plugin was installed, we could see the tests, with this command line:
./gradlew sonarqube -Dsonar.tests=src/test/groovy -Dsonar.junit.reportsPath=build/test-results/test/
We are using Spock as well (with Gradle, as you can see)

Related

Unit Test Coverage is not coming in Sonarqube

I have configured Jenkins 2.31.1 with Maven 3.3.9 , and I am using Sonarqube 5.6.4, when I am building my Java project from Jenkins then test cases are getting executed also I am getting report in Sonarqube but Unit Tests Coverage is coming as "-".
Can anyone explain the steps to resolve this issue? How can I get Unit Tests Coverage? What are the changes I need to do ? What are the steps to be followed? Am I missing something here?
Here is link to my git repository -
https://github.com/swapnil0504/HelloFromMaven.git

How to launch a Grade SonarQube analysis with help of the Jenkins SonarQube plugin

I have installed Sonarqube plugin in Jenkins and configurations are done for SonarQube and sonar-runner in Manage Jenkins->configure System.
I want to trigger analysis for Gradle project. I would like to know the steps to be followed.
The Jenkins SonarQube plugin only allows to easily launch some SonarQube analysis with help of SonarRunner or Maven. If you want to launch a SonarQube analysis with help of the Gradle SonarQube plugin (see the docs) you must manually configure your Jenkins job to execute 'gradle sonarqube'. Simple example for SonarQube with Gradle is provided here.

resource is not indexed in grails project and sonar

I want to use sonar to monitor the junit test code coverage for a grails project. firstly I use grails code coverage plugin to generate the coverage.xml and configure sonar.groovy.cobertura.reportPath property, but there is no data in junit part. So I change the sonar.sources in the pom.xml from grails-app to grails-app/controllers,grails-app/services,grails-app/domain. then the junit code coverage appears but the console shows resource is not index.and the issues part in sonar dashboard becomes 0. How can i solve that? thank you very much.
sonarqube 4.5.1
Groovy sonar plugin 1.0.1
maven 3.2.5
the pom configuration is below:
<sonar.language>grvy</sonar.language>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.surefire.reportsPath>test/reports</sonar.surefire.reportsPath>
<sonar.groovy.cobertura.reportPath>test/reports/cobertura/coverage.xml</sonar.groovy.cobertura.reportPath>
<!--sonar.groovy.codenarc.reportPath>test/CodeNarcReport.xml</sonar.groovy.codenarc.reportPath-->
<sonar.sources>src/groovy,src/java,grails-app/controllers,grails-app/services,grails-app/domain</sonar.sources>
BR,
victor
It seems that your problem is related to the following issue: http://jira.codehaus.org/browse/SONARGROOV-8
Note that the ticket has been resolved and the fix will be part of version 1.1 of the plugin (requires SQ 4.5.2).
As the plugin has not yet been released, you may want to test the snapshot. Please refer to this thread: http://sonarqube.15.x6.nabble.com/VOTE-Groovy-Plugin-version-1-1-td5033128.html

SonarQube 4.4 upgrade can not show test coverage on dashboard

I upgraded my sonarqube from 4.1 to 4.4. as in the latest java plugin 2.4 you don't need to have a JaCoCo plugin. I have deleted the jacoco plugin, but now i can not see Tes coverage on sonar dashboard - it's blank. We use bamboo for CI tool and run sonar build from Bamboo. we run below maven command from bamboo build .
clean verify -Psonar sonar:sonar -U -fae -Dsonar.forceAnalysis=true
With latest versions of the SQ Java plugin, tests are no longer automatically executed. They must be executed prior to the SonarQube analysis and configured so that they produce reports that can be read by the SQ Java plugin.
Everything is explained on the Code Coverage by Unit Tests for Java Project documentation page.

SonarQube Eclipse doesn't show me issues after a local analysis

Using SonarQube Eclipse plugin, I run remote analysis [Sonar > Mode > Remote] (localhost:9000 and ip_on_my_lan:9000) and I see Sonar Issues tab with some elements (everything is OK).
But if I run local analysis I don't have any issue on Sonar Issues tab and Eclipse deletes all issues marks from source code.
It seems sonar-runner local analysis was OK: INFO - ANALYSIS SUCCESSFUL
What I'm doing wrong?
I tried with:
Eclipse Kepler, Sonar 3.7, SonarQube Plugin 3.0 and 3.2
Eclipse Juno, Sonar 3.7, SonarQube Plugin 3.0 and 3.2
Thanks for your time.
I found the problem!!!!
I have my sources on src/test/java instead of src/main/java (test framework)
If I run my analysis with "sonar-runner.bat" everything is ok, but when I run a local analysis from eclipse it seems eclipse doesn't found any source, but it doesn't say anything...
Eclipse put the binary code on /target/test-classes/ and I think Sonar plugin can't found it.
So I have two options: Move my source to src/main/java (checked) or create new local analysis properties (sonar.binaries)
Thanks for your time!

Resources