Error observed Code coverage is 0% because it cannot find any TRX files. The log output says
2020-11-17T11:53:10.8683646Z Code coverage command line tool: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
2020-11-17T11:53:10.9803883Z Fetching code coverage report information from TFS…
2020-11-17T11:53:10.9832756Z Attempting to locate a test results (.trx) file…
2020-11-17T11:53:11.3080550Z Looking for TRX files in: D:\a\1\TestResults
2020-11-17T11:53:11.3085054Z No test results files found
2020-11-17T11:53:11.5686761Z Did not find any binary coverage files in the expected location.
2020-11-17T11:53:11.5710157Z Falling back on locating coverage files in the agent temp directory.
2020-11-17T11:53:11.5717338Z Searching for coverage files in D:\a_temp
2020-11-17T11:53:11.6570647Z No coverage files found in the agent temp directory.
2020-11-17T11:53:11.6572560Z Coverage report conversion completed successfully.
Latest version of SonarCloud extension installed in ADO version “1.20.0”
Note that SonarCloud integration is brand new for us and the Pipeline currently uses the following two steps to get covergae report
The built-in mechanism for detecting Code Coverage (or Test files) inside the Scanner for .NET works as follow :
We try to detect if there’s any file inside the legacy TestResults folder inside the System.DefaultWorkingDirectory (this is what you see as “Looking for TRX files in: D:\a\1\TestResults”)
Then if no file found, we fallback into the TempDirectory, where most of the VsTest v2 task output is located.
Please note also that Cobertura is not supported for .NET code, you have to provide either Visual Studio Code Coverage, dotCover, OpenCover, Coverlet or NCover 3 for CodeCoverage, or VSTest, NUnit or xUnit for TestResults.
Note I have switched to opencover rather than Cobertura after you said it was not supported. Does this look right?
I am still getting
Fetching code coverage report information from TFS…
Attempting to locate a test results (.trx) file…
Looking for TRX files in: D:\a\1\TestResults
No test results files found
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.
I deleted my last reply because it was nonsense. Yes our test tasks run before the code analysis task. They are also before the SonarCloudPrepare task.
Can you explain the relationship between the trx files that the SonarCloudAnalyze is saying it cannot find and the CoverletOutput XML files that I am point Sonarsource at with the sonar.cs.opencover.reportsPaths property?
We did have three seperate DotNetCoreCLI - ‘test’ tasks but I have cut that down for simplicity sake. These are the SonarCloudPrepare, DotNetCoreCLI and SonarCloudAnalyze steps