[ExcludeFromCodeCoverage] attribute does not work on methods
See original GitHub issueHi,
I’ve been struggling with adding [ExcludeFromCodeCoverage]
attribute . For some reason, coverlet ignores it when I decorate any method for exclusion. However, it seems to be working fine when I add it to a class. I’ve created a project on github that reproduces this issue.
https://github.com/ssztangierski/coverlet-exclude-attribute
command when I run test from “WeatherControllerTests” folder:
dotnet test WeatherController.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
I’d like to exclude CreateHostBuilder
method from Program.cs
Is this intended or am I doing something wrong? There is also coverage.cobertura.xml file in the repo.
<class name="CoverageTest.Program/<>c" filename="Program.cs" line-rate="0" branch-rate="1" complexity="1">
<methods>
<method name="<CreateHostBuilder>b__1_0" signature="(Microsoft.AspNetCore.Hosting.IWebHostBuilder)" line-rate="0" branch-rate="1">
<lines>
<line number="25" hits="0" branch="False" />
<line number="26" hits="0" branch="False" />
<line number="27" hits="0" branch="False" />
</lines>
</method>
</methods>
<lines>
<line number="25" hits="0" branch="False" />
<line number="26" hits="0" branch="False" />
<line number="27" hits="0" branch="False" />
</lines>
</class>
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
C# ExcludeFromCodeCoverage on method scope not ...
I had found that issue but since we do not use coverlet and the excludefromcodecoverage attribute docs say that it works on method...
Read more >ExcludeFromCodeCoverage not working for CloseAsync ...
I'm using Sonar-cube to test the code coverage. When I run the report to see the code coverage, it shows that OpenAsync method...
Read more >ExcludeFromCodeCoverage not working on async methods
A method marked as async returning any Task/Task<> is ignored by the ExcludeFromCodeCoverage attribute. I'm working with Xamarin and some ...
Read more >ExcludeFromCodeCoverage not working - Build/Test Issues
ExcludeFromCodeCoverage doesn't work here because at a physical level, the attribute doesn't get applied to the compiler-generated IL structure ...
Read more >ExcludeFromCodeCoverageAttri...
Placing this attribute on a class or a structure excludes all the members of that class or structure from the collection of code...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FYI current changelog https://github.com/tonerdo/coverlet/blob/master/Documentation/Changelog.md
Thanks a lot!