通过 .runsettings 从代码覆盖率中排除 Blazor 页面
我有这个小 Blazor 应用程序。现在,我想通过 .runsettings
从代码覆盖率中排除所有 Blazor 页面。这些页面位于 /RaspiFanController/Pages/
下。我的测试使用 NUnit,覆盖率计算使用 coverlet。
我已经尝试使用以下内容创建文件 /Tests/.runsettings
:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations for data collectors -->
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<Functions>
<Exclude>
<Function>.*Pages.*</Function>
</Exclude>
</Functions>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
不幸的是,代码覆盖率仍然包含 Blazor 页面 - 都在 JetBrains Rider 中并通过 dotnet test --收集:“XPlat 代码覆盖率”
。
编辑:我不一定要通过 .runsettings
解决这个问题。如果可以通过csproj
我也很好
I have this little Blazor application. Now I'd like to exclude all Blazor pages from code coverage via .runsettings
. The pages are located under /RaspiFanController/Pages/
. My tests are using NUnit and the coverage calculation uses coverlet.
I've already tried to create the file /Tests/.runsettings
with the following content:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations for data collectors -->
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<Functions>
<Exclude>
<Function>.*Pages.*</Function>
</Exclude>
</Functions>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
Unfortunately, the code coverage still contains the Blazor pages - both within JetBrains Rider and via dotnet test --collect:"XPlat Code Coverage"
.
Edit: I'm not bound to solve this via .runsettings
. If it is possible via csproj
I'm also fine ????
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.runsettings
文件必须如下所示:在我的例子中,我必须将此文件显式传递给
dotnet test
,因此命令如下所示:dotnet test --collect:"XPlat Code Coverage" --no-restore --settings coverlet.runsettings
不幸的是,JetBrains Rider/dotCover 在计算代码覆盖率时不遵循这些设置。
The
.runsettings
file has to look like this:In my case I had to pass this file explicitly to
dotnet test
, so the command looks like this:dotnet test --collect:"XPlat Code Coverage" --no-restore --settings coverlet.runsettings
Unfortunately, JetBrains Rider/dotCover does not honor these settings when calculating the code coverage.