We have a CI pipeline running unit tests that generates opencover.xml files and creates a code coverage html page for that.
We can see the code coverage, I can see these .opencover.xml files exist but sonarqube doesn’t seem to care about it very much.
I’ve already migrated it from coverlet to opencover because I didn’t see any documentation suggesting that the C# analyzer supports coverlet.
I’ve added these additional properties:
SonarQube recognizes that I have tests so it’s detecting the trx files but it give’s me the following output:
Property 'sonar.cs.vstest.reportsPaths' provided, skipping the search for TRX files in default folders...
No code coverage attachments were found from the trx files.
Did not find any binary coverage files in the expected location.
Falling back on locating coverage files in the agent temp directory.
Searching for coverage files in D:\a\_temp
No coverage files found in the agent temp directory.
Coverage report conversion completed successfully.
Process returned exit code 0
The TFS Processor has finished
I’ve already looked at a lot of stackoverflow and articles within this community but they all seem to be slightly different from my issue.
I think the underlying issue may be that we don’t generate .coveragexml files but I don’t want to add more steps to my already pretty large pipeline if I don’t need to.
Please note that SonarQube v8.9 is now the minimum supported version of SonarQube. You should consider an upgrade at your earliest convenience.
I believe that the analysis logs will have information that will help me to isolate what the issue could be. Please set your log level to DEBUG (not trace) and send me a zip of the log.
Hi,
I double-checked and we’re actually on Version 8.8 (build 42792) and I imagine the maintainers will update shortly. I just copied from my last message, sorry.
About the debug log, how do I do that and what kind of information is stored in there?
We’re doing quite a sensitive project so I can’t just share anything.
I understand you may need to redact sensitive information. Logs are quite helpful, though. I’m wanting to discover is what the logs show that the analyzer thinks the value you gave for reportsPaths.
Your logs are insightful. The analyze log from line 10172 says:
INFO: Sensor C# Tests Coverage Report Import [csharp]
DEBUG: Analyzing coverage with wildcardPatternFileProvider with base dir 'D:\a\1\.' and file separator '\'.
DEBUG: Pattern matcher extracted prefix/absolute path 'D:\a\1' from the given pattern 'D:\a\1\s/**/TestResults/**/coverage.opencover.xml'.
DEBUG: Gathering files for wildcardPattern 's/**/TestResults/**/coverage.opencover.xml'.
DEBUG: Pattern matcher returns '0' files.
WARN: Could not find any coverage report file matching the pattern 'D:\a\1\s/**/TestResults/**/coverage.opencover.xml'. Troubleshooting guide: https://community.sonarsource.com/t/37151
DEBUG: Analyzing coverage after aggregate found '0' coverage files.
DEBUG: The total number of file count statistics is '0'.
INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=183ms
INFO: Sensor C# Unit Test Results Import [csharp]
DEBUG: Pattern matcher extracted prefix/absolute path 'D:\a\1' from the given pattern 'D:\a\1\s/**/TestResults/*.trx'.
DEBUG: Gathering files for wildcardPattern 's/**/TestResults/*.trx'.
DEBUG: Pattern matcher returns '0' files.
INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=188ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=93ms
Hmm that is interesting, since we use that same value to generate a code coverage report for the azure DevOps summary with the same variable in fact.
I will have a look at the troubleshooting guide and get back to you.
In my efforts to try to make it work I started adding these reportPath settings.
Now it appears that setting the sonar.cs.vstest.reportsPaths ignores the rest.
In my case that’s fine though because we only have opencover reports.