0
votes

I am having a javascript application, In which I want to do code validation with coverage reports using sonar. While executing mvn sonar:sonar -Pjs with SonarQube version: 3.5.1, It is not executing js unit test.

When I tried the same application with Sonar version: 3.3.1. It is executing js unit test and report is displayed with unit test and coverage (Works great).

What is wrong with SonarQube version: 3.5.1 ? Am i missing anything ?

I have specified the console log of both sonar execution with the command mvn sonar:sonar -Pjs

Logs : SonarQube version: 3.5.1

[INFO] [13:35:18.697] Compare over 5 days (2013-09-28, analysis of 2013-10-03 13:27:35.255)
[INFO] [13:35:18.706] Compare over 30 days (2013-09-03, analysis of 2013-10-03 13:27:35.255)
[INFO] [13:35:18.738] Profile: Sonar way
[INFO] [13:35:19.139] Base dir: /Users/users/mvnsonarsonarRes
[INFO] [13:35:19.140] Working dir: /Users/users/mvnsonarsonarRes/target/sonar
[INFO] [13:35:19.140] Source dirs: /Users/users/mvnsonarsonarRes/src/main/webapp/js
[INFO] [13:35:19.140] Test dirs: /Users/users/mvnsonarsonarRes/src/test/webapp
[INFO] [13:35:19.140] Binary dirs: /Users/users/mvnsonarsonarRes/target/classes

Sonar version: 3.3.1

[INFO] [13:09:38.781] Compare over 5 days (2013-09-28)
[INFO] [13:09:38.781] Compare over 30 days (2013-09-03)
[INFO] [13:09:39.218] Execute maven plugin jstest-maven-plugin...
[INFO] [13:09:39.218] Execute net.awired.jstest:jstest-maven-plugin:1.0:test...
-------------------------------------------------------
 J S   T E S T S
-------------------------------------------------------
Run suite: Login, Agent: emulator
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 10 ms
Results :
Run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 435ms, Coverage : 100%, Agent: emulator
[INFO] For total coverage check with sonar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ---------------------

[INFO] [13:10:24.750] Execute net.awired.jstest:jstest-maven-plugin:1.0:test done: 45532 ms
[INFO] [13:10:24.750] Execute maven plugin jstest-maven-plugin done: 45532 ms
[INFO] [13:10:24.750] Initializer JsTestMavenInitializer...
[INFO] [13:10:24.750] Initializer JsTestMavenInitializer done: 0 ms
[INFO] [13:10:24.750] Initializer ProjectFileSystemLogger...

Am i missing anything ?

1
What does your js profile look like?marc.guenther

1 Answers

0
votes

There could be two problems. SonarQube requires the build and the sonar run to be two separate maven calls. See sonar (very bottom of the page).

Our setup was as follows:

mvn install -Dmaven.test.skip=true
mvn sonar:sonar

This resulted still in no code coverage, exactly like your reported problem. This was caused by the option "-Dmaven.test.skip=true". This resulted in the test code not being compiled and therefore not run during the sonar run, see maven.

Our code coverage was back again after changing this to:

mvn install -DskipTests
mvn sonar:sonar