Template for a good new topic, formatted with Markdown:
- ALM used (GitHub, Bitbucket Cloud, Azure DevOps) - Azure DevOps
- CI system used (Bitbucket Cloud, Azure DevOps, Travis CI, Circle CI - Azure DevOps
- Scanner command used when applicable (private details masked) - sonar-scanner.bat
- Languages of the repository - TSQL Project solutions
- Only if the SonarCloud project is public, the URL
- And if you need help with pull request decoration, then the URL to the PR too
- Error observed (wrap logs/code around with triple quotes ``` for proper formatting) - Code coverage is showing 0.0% for TSQL (contains Stored Procedures and other database objects like Table, scripts etc)
- Steps to reproduce
Trying to get code analysis for TSQL projects (contains Stored Procedures and other database objects like Table, scripts etc). I tried to implement this like .Net project, build task and VSTEST task in between Prepare task and Run analysis. It is working fine but its adding the Unit Test case .cs file also in the code coverage.
Then removed the Unit Test dll using below tag in tag of .runsettings then the code coverage is not enable after build. Please help to solve this issue.
Exclude Tag in runsettings file
ModulePath tag - .*tests.dll
ModulePath tag - .*Tests.dll
- Potential workaround - Dont know.
Any assistance you can provide would be greatly appreciated.
Hi @supravat.samanta , welcome to the community.
So this is expected to not have any .NET file analyzed with sonar-scanner.bat, because you need to execute the Scanner for .NET (as you have seen with the last part of your message).
Tests projects file might not be included in the analysis, did you have spot why you have these ? Have you seen code related to that in the Code tab on SonarCloud ?
Thank you so much for the update. We are using now .runsettings & SonarScanner.MSBuild.exe for TSQL projects for code coverage of database stored procedures. How to exclude the Unit Test class(.cs files) which was written for store procedure unit test case.
We have seen in many blogs to add the below tag to exclude Unit test class .cs files from code coverage in the .runsettings file.
But once we add this then the code coverage tab is not enabled in the Azue DevOps tab after the build so we can not see the code coverage.
Please let us know is there any other way to exclude the Unit Test case files from code coverage for TSQL projects.
Any help will be much appreciated.
I think we are mixing 2 things here : Code Coverage on Azure DevOps summary tab, and the one displayed on SonarCloud.
The main difference is that on SonarCloud, test files are, by default, excluded from analysis and therefore coverage. There’s a setting however to activate it if you wish (the analysis on those one, probably not the coverage).
So at the end, what do you want to achieve ?
There’s a setting however to activate it if you wish (the analysis on those one, probably not the coverage - Could you please let us know the setting to enable code coverage. Hope the setting will be in Azure pipeline.
Also for us we are not able to see the code coverage in Sonar cloud as well.
You can try to add this to the extra properties :