gpt4 book ai didi

azure-devops - 提供 .runsettings 文件时,VSTS 中没有代码覆盖率

转载 作者:行者123 更新时间:2023-12-04 12:03:47 26 4
gpt4 key购买 nike

我们在 Visual Studio Online (VSTS) 构建定义中遇到代码覆盖率问题,当我们定义自定义 .runsettings 文件时,不会返回任何结果。

这在本地工作正常,但是,当我们使用此文件更新 Visual Studio Online 上的构建定义时,它不会返回任何结果。

我的 .runsettings 文件,根据我找到的一个例子,我把所有东西都留在了那里。

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<ResultsDirectory>.\TestResults</ResultsDirectory>
<TargetPlatform>x86</TargetPlatform>
<TargetFrameworkVersion>Framework40</TargetFrameworkVersion>
<TreatTestAdapterErrorsAsWarnings>false</TreatTestAdapterErrorsAsWarnings>
<CollectSourceInformation>true</CollectSourceInformation>
<MaxCpuCount>0</MaxCpuCount>
</RunConfiguration>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Include>
<ModulePath>.*\.dll$</ModulePath>
<ModulePath>.*\.exe$</ModulePath>
</Include>
<Exclude>
<ModulePath>.*CPPUnitTestFramework.*</ModulePath>
<ModulePath>.*TestAdapter.*</ModulePath>
<ModulePath>.*xamarin.*</ModulePath>
</Exclude>
</ModulePaths>
<Functions>
<Exclude>
<Function>^Fabrikam\.UnitTest\..*</Function>
<Function>^std::.*</Function>
<Function>^ATL::.*</Function>
<Function>.*::__GetTestMethodInfo.*</Function>
<Function>^Microsoft::VisualStudio::CppCodeCoverageFramework::.*</Function>
<Function>^Microsoft::VisualStudio::CppUnitTestFramework::.*</Function>
</Exclude>
</Functions>
<Attributes>
<Exclude>
<Attribute>^System.Diagnostics.DebuggerHiddenAttribute$</Attribute>
<Attribute>^System.Diagnostics.DebuggerNonUserCodeAttribute$</Attribute>
<Attribute>^System.Runtime.CompilerServices.CompilerGeneratedAttribute$</Attribute>
<Attribute>^System.CodeDom.Compiler.GeneratedCodeAttribute$</Attribute>
<Attribute>^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$</Attribute>
<Attribute>^NUnit.Framework.TestFixtureAttribute$</Attribute>
<Attribute>^Xunit.FactAttribute$</Attribute>
<Attribute>^Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute$</Attribute>
</Exclude>
</Attributes>
<Sources>
<Exclude>
<Source>.*\\atlmfc\\.*</Source>
<Source>.*\\vctools\\.*</Source>
<Source>.*\\public\\sdk\\.*</Source>
<Source>.*\\microsoft sdks\\.*</Source>
<Source>.*\\vc\\include\\.*</Source>
</Exclude>
</Sources>
<CompanyNames>
<Exclude>
<CompanyName>.*microsoft.*</CompanyName>
</Exclude>
</CompanyNames>
<PublicKeyTokens>
<Exclude>
<PublicKeyToken>^B77A5C561934E089$</PublicKeyToken>
<PublicKeyToken>^B03F5F7F11D50A3A$</PublicKeyToken>
<PublicKeyToken>^31BF3856AD364E35$</PublicKeyToken>
<PublicKeyToken>^89845DCD8080CC91$</PublicKeyToken>
<PublicKeyToken>^71E9BCE111E9429C$</PublicKeyToken>
<PublicKeyToken>^8F50407C4E9E73B6$</PublicKeyToken>
<PublicKeyToken>^E361AF139669C375$</PublicKeyToken>
</Exclude>
</PublicKeyTokens>
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<CollectAspDotNet>False</CollectAspDotNet>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<MSTest>
<MapInconclusiveToFailed>True</MapInconclusiveToFailed>
<CaptureTraceOutput>false</CaptureTraceOutput>
<DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
<DeploymentEnabled>False</DeploymentEnabled>
</MSTest>
</RunSettings>

更新 1

这是我本地环境中相同运行设置文件的输出,附加到 Visual Studio 作为要使用的文件:

enter image description here



enter image description here

此设置文件的作用是从分析中排除 Xamarin.Forms.*.dll,因为我们不应在项目中覆盖这些程序集。

如您所见,它在本地工作,但是当我在 VSTS 的构建运行中使用此设置文件时,它给了我以下信息:

enter image description here

我试过浏览日志,并没有发现我们所做的有什么问题。我正在设置内部部署的 TFS 2017 安装以进行测试,至少我可以访问输出目录以查看构建过程中会发生什么。

我不熟悉这个,所以我正在尝试任何可能的答案。

最佳答案

我在 AzureDevOps OnPremise 2020 上有以下解决方案,带有 asp .net app .它在我的场景中运行良好,我必须将结果转换为 Cobertura(对于 sonarqube)。我认为对你来说重要的任务是 'dotnet 测试' 任务(见下文):
以下是构建管道部分:

 - task: DotNetCoreCLI@2
displayName: 'dotnet test'
inputs:
command: test
arguments: '--configuration $(buildConfiguration) --no-build --logger trx --collect "XPlat Code coverage" --settings coverlet.runsettings'
projects: '**/*Test/*.csproj'
publishTestResults: true

- task: DotNetCoreCLI@2
displayName: Install ReportGenerator tool
inputs:
command: custom
custom: tool
arguments: update --tool-path . dotnet-reportgenerator-globaltool --ignore-failed-sources

- script: reportgenerator -reports:$(Agent.TempDirectory)/**/coverage.opencover.xml -targetdir:$(Build.SourcesDirectory)/coverlet/reports -reporttypes:"Cobertura"
displayName: Transform coverage reports

- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: '$(Build.SourcesDirectory)/coverlet/reports/Cobertura.xml'
failIfCoverageEmpty: false
覆盖 azureDevOps:
enter image description here

关于azure-devops - 提供 .runsettings 文件时,VSTS 中没有代码覆盖率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47055354/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com