Hello everyone,
we have a problem in that we can no longer see some of the metrics after upgrading to server version 2025.1.1.104738. We haven’t changed the way we generate the coverage/trx files. All other metrics are available except for these. Can anyone help me with this?
Thanks for the log. In it, I see the test execution report being parsed, starting at line 3203, and then starting at 3442, there are a bunch of lines that look like this:
2025-04-28T06:10:04.3675884Z 06:10:04.363 DEBUG: Test method Collectors_uTest.Collectors_uTest.AzureDevOpsProjectRepositoriesCollectorTest.Execute_IsNull_GitRepo cannot be mapped to the test source file. The test will not be included.
So it looks like analysis is skipping reporting on tests that it didn’t find in the project. So I suppose the paths in the execution report don’t match the paths analysis is seeing. Does that make sense?
thanks for the reply. I think you’re basically right. Sonar can’t find any tests that are referenced in the *.trx file.
We noticed that the SonarQubeAnalyze task reads the test files (in log line 92), but we don’t see .sonar.tests set anywhere. It is literally not there. Shouldn’t all files that match a certain pattern (i.e., test files) be set there? We already tried setting the path to the tests in the SonarQubePrepare task, but without success.
Hi,
At least for this one project, we were able to find the cause of the error. You were right in assuming that the tests could not be found.
The problem is the use of this tag <SonarQubeExclude>true</SonarQubeExclude> in the test project (*.csproj) at the project level. Once this tag is removed, the scan works as it did before the server update.
Apart from the fact that the scan works again, there is the unpleasant side effect that the test projects are also analyzed by SonarQube.
Is there a way to avoid this without crippling the scan?
Using sonar.exclusions= in the SonarQubePrepare task is also not a solution, as it triggers the same behavior as <SonarQubeExclude>true</SonarQubeExclude>.
Theoretically, there is no reason not to do this. However, I would like to point out two things:
It should be an option to choose whether or not the test code should be analyzed.
It represents a breaking change. Before the major server upgrade, this was not a problem. The test code could be excluded from the Sonar analysis, and the actual product code was still analyzed correctly.
Point two in particular is really hitting us hard. We have a medium number of teams that now have a real problem. We tested it on a really small product (removing exclusions) and the Sonar rules that are applied to the test code are really picky.
Is there a way to apply a rule set (containing no or only a few rules) to the tests themselves? Or is there even a way to restore the old behavior?