Attribute filter syntax for code coverage in TeamC

2020-08-26 04:24发布

问题:

Anyone knows the syntax for excluding code from coverage in Teamcity? I am using the ExcludeFromCodeCoverageAttribute on certain methods and want those excluded. It works well in Visual Studio but I don't understand how to get the same behavior in TeamCity. The Field I am trying to configure is located in MsTest -> .Net Coverage -> Attribute Filters: I have tried this:

-:ExcludeFromCodeCoverageAttribute 

and this

-:ExcludeFromCodeCoverage

回答1:

After trying out a few variations this worked:

-:System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute


回答2:

Make sure you add this filter inside Attribute Filter:

-:System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute