Hi Duncan,
Thank you for the reply, it set me in the right direction.
I got this fixed, the main problem was that dotnet test --collect "code coverage"
was generating coverage report that contained just coverlet dll, no actual project dll.
coverlet.collector.dll
coverlet.core.dll
I tried to get this working in many ways, I still don’t understand why it works in a different project with same nuget versions and style of tests. in the end gave up and decided to use do this myself:
dotnet test PathTo.Tests.csproj --logger "trx;LogFileName=testresults.trx" /p:CollectCoverage=true "/p:CoverletOutputFormat=\"cobertura,opencover\""
Cobertura output is needed for VSTO, because it does not support opencover:
- task: PublishCodeCoverageResults@1
displayName: 'Publish coverage results'
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: 'pathToReports/coverage.cobertura.xml'
Opencover is needed for sonar cloud task SonarCloudPrepare@1:
extraProperties:'sonar.cs.opencover.reportsPaths=$(workingDirectory)/LaunchBDataCollector.Unit.Tests/coverage.opencover.xml'
Last thing is to publish tests to VSTO:
- task: PublishTestResults@2
inputs:
testRunner: VSTest
testResultsFiles: '**/*.trx'
failTaskOnFailedTests: true
Hope this is helpful for other people.