SonarC# support for code to unit test linking

In some plugins, i see that a unit test link is given when browsing the source code branch that has unit tests and coverage data provided for it. In the c# plugin, it just says “fully covered by unit tests”.

In terms of developer workflow, having the unit test reference on this page, allowing quick navigation to the unit test, would really help Sonar become a core tool at our organisation. This small gap is a big blocker.


Unfortunately I think you’re using a very old version of SonarQube… AFAIK this feature was completely removed in SonarQube 7.5. The unit test details aren’t saved anymore.

Well its not that im using an old version of sonar, its that i find sonar very hard to configure correctly - and that its really “magic” if one of these features works or not. The configuration required for coverage requires atleast 3 settings to be in alignment, and you have no idea what setting you need to configure for this magic to happen.

Its kind of puzzling why this feature was removed. Its simple, and gives alot of value in making Sonar a central tool for devs on a daily basis.

Hi @Jono - did you read [Coverage & Test Data] Generate Reports for C#, for unit tests and coverage?

Of course i did. If u are running a mixed code project - like TS, JS and C#, you have exponentially more failure points.

there is no mention of the plethora of issues that can occour to stop these stats from being reported, including but not limited too, file paths being incorrectly logged in each of the output files. ive had too write many scripts that take the outputs of various reports, and re-mangle them for SQ ingestion.

Not even my fully modern Electron/TS/Angular stack worked out of the box. Some plugins work for a few releases, then fail after a SQ/npm update. Or a test file, which is valid for a test runner, but maybe not fully syntactically correct, will fail for SQ ingestion silently and just report “no tests”.

Im the devops lead at my company and I feel like my entire life is spent decoding SQ logs and answering questions about why this or that statistic has stopped working suddenly. My longest sonar project takes 2hrs to run against. The test suite takes 24hrs to run. Small issues like this, and the fact that SQ gives you no context as to what is broken, turn my job into a cluster.

IE. if SQ said to me “yes we have a coverage report, we have a unit test report, but we are not showing you any results because the coverage report file path is relative, and the unit test report is absolute” it would make my life soooooo much easier. But it doesnt. It just doesnt work and errors out with the same codes.

Yes, and we plan to improve this. For now, the working solution (that we use internally as well) is for each technology stack to have a separate SQ project.

This seems a problem we will want to investigate. Can you please open a different topic in the report a bug section?

Is this related to SonarQube ?

Can you please open a different topic to describe this problem - what the logs say and what they should say?

On the dotnet side, we’ve made some improvements in the last months of 2019 regarding debug logging for the import of code coverage and unit test results. Please make sure you update to the latest version of SonarCSharp / SonarVBNet (from the SQ Marketplace), or that you already are using SonarCSharp 8.1. Otherwise, we may just tell you “we’ve already improved this”.