如何在 TeamCity 中排除 dotCover 覆盖的类型和方法?
我有一个现有的 C# 4 项目,我已使用 TestDriven.Net 和 Visual Studio 覆盖率功能检查了该项目的测试覆盖率,即 Test With ->上下文菜单的覆盖范围。
该项目包含一些我不想覆盖的代码,我已经通过为这些类型和方法添加 [ExcludeFromCodeCoverage]
解决了这个问题。
我们刚刚将 TeamCity 升级到 6.0.3,并且我在 NUnit 构建步骤中添加了 dotCover 覆盖范围。
我已经设法在“过滤器”部分中删除对外部程序集(例如 NHibernate)的覆盖(通过明确说明我想要覆盖的程序集),但我正在努力解决如何从所覆盖的程序集中排除类型和方法。
I've got an existing C# 4 project which I've checked the test coverage for by using TestDriven.Net and the Visual Studio coverage feature, i.e. Test With -> Coverage from the context menu.
The project contains some code I don't want covered, and I've solved that by adding the [ExcludeFromCodeCoverage]
for those types and methods.
We've just upgraded TeamCity to 6.0.3, and I've added dotCover coverage to the NUnit build step.
I've managed to remove coverage for external assemblies such as NHibernate in the "Filters" section (by explicitly state the assemblies for which I want coverage), but I'm struggling with how to exclude types and methods from covered assemblies.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,马丁,我明白了!仅花了一个小时随机查看过滤器语法...当文档说要添加这样的过滤器时,
他们的真正意思是...其中
<>
中的任何内容都完全替换为你和其他任何东西都是文字所以,我想要的过滤器是包含一个程序集(来自一堆程序集),然后排除该程序集中的一些命名空间。我写
Ok, Martin, I figured it out! It only took an hour of randomly poking at the filter syntax... when the documentation says to add a filter like this
They really mean this... where anything in
<>
is replaced entirely by you and anything else is a literalSo, the filter I wanted was to include a single assembly (from a bunch of assemblies) and then exclude a few namespaces in that assembly. I wrote
查看命令行的覆盖率分析 - 应用过滤器页。看起来您可以在“过滤器”部分中设置排除项,类似于排除整个程序集的方式。
假设您想要忽略
MyStuff
类中包含的名为DoStuff
的方法,该类位于MyAwesomeAssembly
库中。那么您的 dotCover XML 应该如下所示:免责声明: 我不使用 dotCover,所以我不能 100% 确定这是否真的有效。
Take a look at the Coverage Analysis from the Command Line - Applying filters page. It looks like you can set up exclusions in the Filters section, similar to how you excluded entire assemblies.
Let's say you want to ignore a method called
DoStuff
contained in a classMyStuff
, which is in theMyAwesomeAssembly
library. Then your dotCover XML should look something like this:Disclaimer: I don't use dotCover, so I'm not 100% sure if this will actually work.
TeamCity 文档关于过滤器选项的说明如下:
使用以下语法指定要分析每行一个的程序集:+:myassemble=;type=;method=*
使用
-:我的程序集
从代码覆盖率中排除程序集。此处支持星号通配符 (*)。
This is what the TeamCity docs says about the filter options:
Specify assemblies to profile one per line using following syntax: +:myassembly=;type=;method=*
Use
-:myassembly
to exclude an assembly from code coverage. Asterisk wildcard (*) is supported here.