Code coverage report for TSQLT on SonarQube not showing up

Hello All,

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,

  1. Compile the sql project
  2. Deploy the dacpac on database
  3. Run TSQLT tests using SQLCover
  4. Exporting the results in Coverage.opencoverxml file
  5. 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)
  6. Adding below property in SonarQubePrepare task,
    sonar.sql.tsql.sqlcover.report=\SonarQube.xml
    Also tried below but no luck,
    sonar.coverageReportPaths=
    \SonarQube.xml
  7. 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?

Thanks in Advance!

Hey there.

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).

Hi @Colin_SonarSource

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.

Support for a coverage tool varies by analyzer – the coverage formats supported for C# are different than those for TSQL.

A quick search led me to some tools on GitHub, like GitHub - jmecosta/OpenCover2SonarConverter: Converts OpenCover to SonarQube format

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.