We’re using the standalone Sonar Scanner to analyse the output from our Microsoft SQL server builds. For some reason we cannot get Sonar Cloud to report on the code coverage for our T-SQL code. We’ve spotted that the SQL tests generate a coverage and a trx file but for some reason no coveragexml file is created. We believe this is why the ‘Run Code analysis’ step in our Azure build pipeline is unable to report on the code coverage.
We’ve already tried adding these settings;
sonar.cs.vscoveragexml.reportsPaths=/*.coveragexml
sonar.cs.vstest.reportsPaths=/*.trx
But no *.coveragexml file appears to be created.
Any ideas?
Hi @Roadkingscot ,
Are you using the Scanner in a Azure DevOps context by chance ?
Mickaël
Yes. We are using the scanner on a build agent as part of the build pipeline. C# code coverage works absolutely fine but we’ve never managed to get coverage for SQL to work. In the ‘classic’ ADO pipeline builder we;
- Prepare the analysis on Sonar Cloud - Using the standalone scanner.
- Build the database solution
- Run the SQL Unit tests on a Visual Studio 2015 test platform on the build server.
- Run the Sonar Cloud code analysis
- Publish the Sonar Cloud result.
We have already added the sonar.cs.vscoveragexml.reportsPaths=**/*.coveragexml in the prepare additional properties.
What we have spotted though is that the SQL unit tests are creating a TRX and coverage file, but the coverage file is not being built into a coveragexml file. We’ve also spotted that 2 coverage files are created for each SQL build. A data.coverage and what looks like a build coverage file.
Any suggestions?
Hi @Roadkingscot
Automatic detection and conversion of coverage files happen if they are located in either :
$(Agent.TempDirectory) folder,
Or, as a fallback, in a TestResults folder.
Is is your case ?
The TRX and coverage file is being created in a TestResults folder under the build artifact staging directory. All of the tests are also running and passing. We just can’t understand why no coveragexml file is created from the coverage file and TRX file.
Can you send me the logs of an execution of the Run Code Analysis task, in debug mode please ? (i can DM you if you prefer to share them privately, let me know)
Thank you.