SQ Version : 7.9.1.27448
I am trying to run the TSQLT tests on database and publish the code coverage report to SonarQube
These are the steps I am following,
Compile the sql project
Deploy the dacpac on database
Run TSQLT tests using SQLCover
Exporting the results in Coverage.opencoverxml file
Convert Coverage.opencoverxml to SonarQube format using ReportGenerator
<?xml version="1.0" encoding="utf-8"?>
<coverage version=“1” /
<file path="[ABC].[abc-cde-ghi-nknknknk]" /
After conversion, I do see all the report getting compiled in html format (Looks good)
Adding below property in SonarQubePrepare task,
sonar.sql.tsql.sqlcover.report=\SonarQube.xml
Also tried below but no luck,
sonar.coverageReportPaths=\SonarQube.xml
No code coverage information on SQ, still shows 0.0%
Can someone help me figure this out? What am I doing wrong?
Same setup works fine for normal C# unit tests but does not work for TSQLT.
Has anyone tried implementing code coverage for TSQLT? Is this even possible?
If you are using gretard/sonar-sql-plugin you are better off asking for help on their Github repository (aka if you’re using a Community Edition of SonarQube).
If you’re using Developer Edition or above (with SonarSource’s T-SQL analyzer), you will need to convert your reports to Generic Test Data before importing them (using the sonar.coverageReportPaths analysis parameter you’ve already found).
We are using Developer edition.
I am following the same procedure for normal C# unit tests by converting DynamicCodeCoverage.coveragexml to SonarQube readable xml which seems to be working fine for code coverage.
But for TSQLT, when I am trying to convert Coverage.opencoverxml to SonarQube format using ReportGenerator, the T-Sql scanner/analyzer does not seems to be working correctly.
Do you know how can I convert the Coverage.opencoverxml to a generic file format so that SQ can read and reflect the matrix on dashboard?
When I checked the analysis log I see lot of these warnings,
WARN: Unable to parse file ‘***.sql’ : Parse error at line 4 column 9:
Not sure if its relevant.
Take note of this section in our documentation on analyzing T-SQL
Important Note
With the default configuration, only files with the .tsql are analyzed as T-SQL, and files with the .sql file extension are analyzed as PL/SQL. This behavior is defined in Administration > General Settings > T-SQL > File Suffixes and Administration > General Settings > PL/SQL > File Suffixes . You can override these properties either at server level or at project level.
Passed this generic data file to SQ prepare task using sonar.coverageReportPaths.
sonar.coverageReportPaths=$(Build.SourcesDirectory)\Databases\merged.cov.json
Still no signs of code coverage Metrix on sonarqube dashboard