Code coverage of SQL unit testing with tSQLt tool and integrating in Sonarqube dashboard

We’re using tSQLt for SQL unit test cases and integrated with Azure DevOps for build pipeline using Redgate SQL Change Automation:build task. Now I got result as “TestResults.junit.xml” and published to Tests summary. But code coverage is not showing. We want to show the this code coverage and want to integrate this coverage with in Sonarqube dashboard.

Kindly suggest on how could we do this. Thanks.

Hi @upendaravireni,

SonarQube doesn’t have native coverage import for T-SQL. So you’ll need to convert your TestResults.junit.xml file to our Generic Coverage format, then set sonar.coverageReportPaths to point to the resulting generic coverage file.

Regards,

Cameron.

Do you have a sample generic format tsqlt code coverage file that i can use for testing?
I am having hard time to convert the xml file to sonarqube generic format.
Any tool you can recommend using to do the conversion?

HI @neet.neet14,

Unfortunately the tsqlt XML format doesn’t seem to be readily available, although according to this release note it’s compatible with this JUnit XSD. So if you can find a JUnit-to-SonarQube conversion, you may get some traction. Since the tsqlt XML format is not one of ours, there’s not a lot more help I can provide here :frowning:

Regards,

Cameron.