Closed SudeepParajuli closed 7 years ago
Hi,
Unit test results import is not provided anymore by SonarJS. For that you should use SQ's native feature Generic Test Data (since SQ 6.2). If you use SQ < 6.2 use this plugin https://docs.sonarqube.org/display/PLUG/Generic+Test+Coverage.
Since my SQ < 6.2 I tried the Generic Test Coverage Plugin with the following changes :
Installed Generic Coverage Plugin 1.2 Edited the sonar.property file with : sonar.genericcoverage.unitTestReportPaths=report
Still I am not able to achieve the unit test result depiction on dashboard.
The XML generated by my mocha-sonar-reporter is in this format :
<testsuite name="Mocha Tests" tests="50" failures="0" errors="0" skipped="0" timestamp="Wed, 20 Sep 2017 04:00:45 GMT" time="3.933">
<testcase classname="app/redux/transaction.spec.js" name="Search actions creates LOCAL_FETCH_SUCCESS when translation fetch done" time="0.01"/>
But for Generic Coverage Plugin it should be in this format :
<unitTest version="1">
<file path="src/test/java/com/example/MyTestClass.java">
<testCase name="test1" duration="500"/>
</testCase>
</file>
</unitTest>
How could I generate the xml in this supported format with mocha . Any idea @vilchik-elena
So kind of you . Thank you @vilchik-elena . It worked .
@vilchik-elena my SQ's version is 6.4 , here i am using mocha for my nodjs project. The code coverage is not getting on the SQ's dashboard, which tool i need to use.
@jithuvijayan1992 create new ticket, put configuration and logs
jithuvijayan1992 please create new issue..
So kind of you . Thank you @vilchik-elena . It worked .
@SudeepParajuli Which one did you used ?
SonarQube Version : 6.0.0 SonarJS: 2.17.0.3154
Issue
The main aim is to display coverage report and the unit test result in SonarQube dashboard. Though I am able to get the coverage report but not able to get the unit test result in SonarQube dashboard . I have been using the mocha for unit testing and istanbul nyc for code coverage. The report generated by mocha is in xml format using the package mocha-sonar-reporter and the coverage report is in lcov format .
_Sonar.Property File
sonar.projectKey=unittest sonar.projectName=unittest sonar.projectVersion=1.0.0
sonar.sources=src/ sonar.tests=test/
sonar.language=js sonar.sourceEncoding=UTF-8 sonar.javascript.jstestdriver.reportsPath=/home/jenkinsbot/workspace/devops_stuffs/reports sonar.javascript.lcov.reportPath=/home/jenkinsbot/workspace/devopsstuffs/reports/lcov.info
SonarQube log :
_[Pipeline] wrap Injecting SonarQube environment variables using the configuration: Sonar(dk.147) [Pipeline] { [Pipeline] sh [e_feature_COS-239-unit-test-P23YKERWYLNSD6K3ISKUHA5NSJTRN6K7DRJGKI5QLG6LTD3HHOPA] Running shell script