4
votes

I have a SBT project with Java,Scala and its integrated with Jenkins for Sonar scan after SBT build. After successful analysis,I can't see the code coverage and unit test coverage in percentages.

The project structure after "sbt clean compile test" is as follows:

le-adaptor
      src->main/java/.. ,main/scala/.. , test/scala/..
      target->classes,test-classes,test-reports
le-ui
      src->main/java/.. ,test/scala/..
      target->classes,test-classes,test-reports
build.sbt

My sonar-project.properties file is as below:

sonar.projectKey=MyProject
sonar.projectName=my sbt project
sonar.projectVersion=0.1.0.0-SNAPSHOT
sonar.languages=java,scala
sonar.modules=le-adaptor,le-ui

le-adaptor.sonar.binaries=target/classes
le-adaptor.sonar.sources=src/main/java,src/main/scala
le-adaptor.sonar.tests=src/test/scala
le-adaptor.sonar.junit.reportsPath=target/test-reports

le-ui.sonar.binaries=target/classes
le-ui.sonar.sources=src/main/java
le-ui.sonar.tests=src/test/scala
le-ui.sonar.junit.reportsPath=target/test-reports

Sonar version is 4.3.2 and plugins installed are:

Checkstyle  2.1.1
Clover  3.0
Cobertura   1.6.3
Fortify 1.0
Generic Coverage    1.1
JMeter  0.3
Java    2.5.1
JavaScript  2.1
LDAP    1.2.1
PMD 2.2
Quality Index   1.1.3
SCM Activity    1.5
Scalastyle  0.0.1-SNAPSHOT
Technical Debt  1.2.1
Total Quality   1.1
Toxicity Chart  0.1
Useless Code Tracker    0.5
Violation Density

When I go to http://localhost:9000/dashboard/index/MyProject , I can't see the percentage code coverage and unit test coverage.

What I'm missing here ? Any help would be appreciated.

1
Scala and so SBT projets are not supported by SonarSource. Try to contact the authors of the SonarQube Scalastyle/Scala plugin. - Freddy - SonarSource Team
You might want to add a screenshot of your site, as no one else will be able to resolve something using a localhost link. - annedroiid

1 Answers

0
votes

Scalastyle plugin for Sonar didn't work for me either.

The most fresh and maintained SonarQube plugin that worked for me is sonar-scala. It currently supports Sonar 6.7.1 LTS and up.

If you have Sonar 5.4 or so, follow this instruction on how to add SCoverage plugin.