NET Core 3.1的Azure DevOps代码覆盖率

编程入门 行业动态 更新时间:2024-10-28 05:20:10
本文介绍了NET Core 3.1的Azure DevOps代码覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在为ASP.NET Core 3.1应用程序设置Azure DevOps管道,并且我具有以下YAML定义测试段),用于构建,测试和代码覆盖.

I am setting up an Azure DevOps pipeline for an ASP.NET Core 3.1 Application and I have the following YAML definition test segment) for building, testing and code coverage.

- task: DotNetCoreCLI@2 displayName: "dotnet global test tool install" inputs: command: 'custom' custom: 'tool' arguments: 'install --global dotnet-reportgenerator-globaltool' - task: DotNetCoreCLI@2 displayName: "dotnet test" inputs: command: 'test' projects: '**/*[Tt]ests' arguments: '--no-build --configuration $(buildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(System.DefaultWorkingDirectory)/TestResults/Coverage' testRunTitle: 'Unit Test' workingDirectory: '$(System.DefaultWorkingDirectory)' - script: reportgenerator -reports:$(System.DefaultWorkingDirectory)/**/cobertura/coverage.xml -targetdir:$(System.DefaultWorkingDirectory)/CodeCoverage -reporttypes:HtmlInLine_AzurePipelines displayName: "create code coverage report" - task: PublishCodeCoverageResults@1 displayName: "publish test coverage result" inputs: codeCoverageTool: 'Cobertura' summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/cobertura/coverage.xml'

在Azure DevOps中运行时,出现以下错误

Upon running in Azure DevOps, I get the following error

我可能做错了什么?项目来源: GitHub

What could I be doing wrong? Project Source: GitHub

推荐答案

最后在Microsoft MVP的帮助下使其工作.共享有效的测试段中的代码.

Finally got it working with the help of a Microsoft MVP. Sharing the code from the test segment that worked.

- task: DotNetCoreCLI@2 displayName: "dotnet global test tool install" inputs: command: 'custom' custom: 'tool' arguments: 'install --global dotnet-reportgenerator-globaltool' - script: dotnet test WebApp.Web.Tests/WebApp.Web.Tests.csproj --logger "trx;LogFileName=testresults.trx" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.SourcesDirectory)/TestResults/Coverage/ displayName: 'dotnet test' - script: reportgenerator "-reports:$(Build.SourcesDirectory)/TestResults/Coverage/coverage.cobertura.xml" "-targetDir:$(Build.SourcesDirectory)/TestResults/Coverage/Reports" -tag:$(Build.BuildNumber) -reportTypes:htmlInline workingDirectory: $(Build.SourcesDirectory)/WebApp.Web.Tests displayName: 'dotnet reportgenerator' - task: PublishTestResults@2 inputs: testRunner: VSTest testResultsFiles: '**/*.trx' failTaskOnFailedTests: true - task: PublishCodeCoverageResults@1 inputs: codeCoverageTool: 'cobertura' summaryFileLocation: $(Build.SourcesDirectory)/TestResults/Coverage/**/coverage.cobertura.xml reportDirectory: $(Build.SourcesDirectory)/TestResults/Coverage/Reports failIfCoverageEmpty: false

可以在此处找到资源.

更多推荐

NET Core 3.1的Azure DevOps代码覆盖率

本文发布于:2023-11-14 10:43:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587004.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:覆盖率   代码   Core   NET   DevOps

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!