我正在尝试使用 vstest.console.exe 生成代码覆盖率报告。我也在使用 .runsettings 文件并将其作为参数传递。
无论我想做什么,它只为moq.dll生成一份报道报告。
我在下面分享我正在运行的命令参数的全文以及.runsettings文件的内容。任何想法,我在哪里做错了什么?
命令:
vstest.console.exe “C:\ Xyz.Tests \ bin \ Debug \ netcoreapp2.0 \ Xyz.Tests.dll”/ InIsolation / EnableCodeCoverage /settings:CodeCoverage.runsettings
CodeCoverage.runsettings 文件内容:
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" enabled="false">
<Configuration>
<CodeCoverage>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
答案 0 :(得分:2)
我遇到了同样的行为,但幸运的是我找到了一个解决方案:
Code coverage enabled
标记--collect:"Code Coverage"
置于其他控制台选项中
在 <DebugType>full</DebugType>
部分
<PropertyGroup>
在.runsettings文件的<ModulePath>.*moq.dll</ModulePath>
部分添加 <ModulePaths> -> <Exclude>
这是我的.runsettings
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<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>
<!-- Match assembly file paths: -->
<ModulePaths>
<Include>
<ModulePath>.*\.dll$</ModulePath>
<ModulePath>.*\.exe$</ModulePath>
</Include>
<Exclude>
<ModulePath>.*moq.dll</ModulePath>
<ModulePath>.*CPPUnitTestFramework.*</ModulePath>
<ModulePath>.*TestAdapter.*</ModulePath>
</Exclude>
</ModulePaths>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>