admin管理员组文章数量:1122846
I'm working on a .NET 4.5 project and trying to use Azure DevOps pipelines to publish the test results but I keep getting an error:
The report file pattern 'D:\a_temp/**/*.xml' found no matching files.
I'm using VSTest@2:
- task: VSTest@2
displayName: '.NET Framework Unit Tests'
inputs:
configuration: 'Release'
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\${{ parameters.projectName }}\${{ parameters.testDllPattern}}.dll
!**\*TestAdapter.dll
!**\obj\**
codeCoverageEnabled: true
otherConsoleOptions: '\collect:Code Coverage;Format=Cobertura'
I understand this task creates a .coverage
file instead of a .xml
.
So I looked around and found this dotnet-coverageconverter.
And I tried to implement it:
- task: DotNetCoreCLI@2
displayName: "Install tool: dotnet-coverageconverter"
inputs:
command: 'custom'
custom: 'tool'
arguments: 'update --global dotnet-coverageconverter'
- task: CmdLine@2
displayName: 'Convert .coverage to .coveragexml'
inputs:
script: 'dotnet-coverageconverter --CoverageFilesFolder "$(Agent.TempDirectory)\TestResults" --verbose'
But then I run the report generator script and it doesn't find any .xml
files:
- script: reportgenerator -reports:$(Agent.TempDirectory)/**/*.cobertura.xml;$(Agent.TempDirectory)/**/*.coveragexml -targetdir:$(Agent.TempDirectory)/TestResults/Coverage/Reports -reporttypes:"HtmlInline_AzurePipelines;Cobertura;Badges;SonarQube"
displayName: 'Create coverage report for Azure Pipeline'
My questions are:
- What am doing wrong?
- Is there any other way of converting this
.coverage
to.xml
?
With .NET Core projects, it's easy with netcli tasks. But with legacy .NET, I'm having trouble.
Thank you in advance.
I'm working on a .NET 4.5 project and trying to use Azure DevOps pipelines to publish the test results but I keep getting an error:
The report file pattern 'D:\a_temp/**/*.xml' found no matching files.
I'm using VSTest@2:
- task: VSTest@2
displayName: '.NET Framework Unit Tests'
inputs:
configuration: 'Release'
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\${{ parameters.projectName }}\${{ parameters.testDllPattern}}.dll
!**\*TestAdapter.dll
!**\obj\**
codeCoverageEnabled: true
otherConsoleOptions: '\collect:Code Coverage;Format=Cobertura'
I understand this task creates a .coverage
file instead of a .xml
.
So I looked around and found this dotnet-coverageconverter.
And I tried to implement it:
- task: DotNetCoreCLI@2
displayName: "Install tool: dotnet-coverageconverter"
inputs:
command: 'custom'
custom: 'tool'
arguments: 'update --global dotnet-coverageconverter'
- task: CmdLine@2
displayName: 'Convert .coverage to .coveragexml'
inputs:
script: 'dotnet-coverageconverter --CoverageFilesFolder "$(Agent.TempDirectory)\TestResults" --verbose'
But then I run the report generator script and it doesn't find any .xml
files:
- script: reportgenerator -reports:$(Agent.TempDirectory)/**/*.cobertura.xml;$(Agent.TempDirectory)/**/*.coveragexml -targetdir:$(Agent.TempDirectory)/TestResults/Coverage/Reports -reporttypes:"HtmlInline_AzurePipelines;Cobertura;Badges;SonarQube"
displayName: 'Create coverage report for Azure Pipeline'
My questions are:
- What am doing wrong?
- Is there any other way of converting this
.coverage
to.xml
?
With .NET Core projects, it's easy with netcli tasks. But with legacy .NET, I'm having trouble.
Thank you in advance.
Share Improve this question edited Nov 25, 2024 at 5:56 Daniel Mann 59k13 gold badges105 silver badges127 bronze badges asked Nov 22, 2024 at 15:16 WeedosaurusWeedosaurus 1641 silver badge9 bronze badges2 Answers
Reset to default 0When using VSTest@2
task, code coverage report is saved in a .coverage
file and will be published to the pipeline automatically by default.
According to your yaml file, you have changed the code coverage format to Cobertura
by otherConsoleOptions: '\collect:Code Coverage;Format=Cobertura'
. In this case, the report is saved in a .cobertura.xml
file, which can be seen in the log of VSTest@2
task. To publish this report to the pipeline, you can use PublishCodeCoverageResults@1 task or reportgenerator@5 task.
- task: VSTest@3
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: '**\bin\**\*Collector.dll'
searchFolder: '$(System.DefaultWorkingDirectory)'
codeCoverageEnabled: true
otherConsoleOptions: '/collect:"Code Coverage;Format=Cobertura"'
configuration: '$(buildConfiguration)'
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage report'
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: '$(Agent.TempDirectory)/**/*.*.cobertura.xml'
Or
- task: reportgenerator@5
inputs:
reports: '$(Agent.TempDirectory)/**/*.*.cobertura.xml'
targetdir: 'coveragereport'
publishCodeCoverageResults: true
Result:
After some research I found a way to achieve my goal with coverlet and by disabling auto generate coverage:
stages:
- stage: Build
variables:
disable.coverage.autogenerate: 'true' -> Disabling autogenerate coverage
jobs:
- job: BuildPackage
steps:
- checkout: self
- checkout: TestAutomation
(..)
Then installing and using a coverlet script:
- task: DotNetCoreCLI@2
inputs:
command: custom
custom: tool
arguments: install --tool-path . coverlet.console
displayName: Install Coverlet.Console tool
- task: PowerShell@2
inputs:
targetType: inline
script: |
Get-ChildItem **\${{ parameters.projectName }}\**\bin\* -Filter "*.framework.tests.dll" -Recurse |
Foreach-Object {
.\coverlet.exe $_.FullName --target "dotnet" --targetargs "vstest $($_.FullName) --logger:trx" --format "cobertura"
$NewName = $_.Name + ".coverage.cobertura.xml"
Rename-Item coverage.cobertura.xml $NewName
Write-Host "Generated Coverage Report: $NewName at $(Get-Location)"
}
displayName: Generate Coverlet coverage report for test libraries
Then, since coverlet creates the xml file in the default working directory:
- script: reportgenerator -reports:$(Agent.TempDirectory)\**\*.cobertura.xml;$(System.DefaultWorkingDirectory)\*.cobertura.xml -targetdir:$(Agent.TempDirectory)/TestResults/Coverage/Reports -reporttypes:"HtmlInline_AzurePipelines;Cobertura;Badges;SonarQube"
displayName: 'Create coverage report for Azure Pipeline'
The first directory is for a .net core project and the second with System.DefaultWorkingDirectory is for the .Net project I was having troubles with.
To finish it off I also do a Publish:
- task: PublishCodeCoverageResults@2
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(Agent.TempDirectory)\TestResults\Coverage\Reports\Cobertura.xml'
I already had this publishing task but it was not reaching since it was failing in the reportgenerator script task.
本文标签: netAzure DevOpsNo testing results found using VSTest2 taskStack Overflow
版权声明:本文标题:.net - Azure DevOps - No testing results found using VSTest@2 task - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736302848a1931679.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论