ExcludeFromCodeCoverage skipped for some lines in excluded method
See original GitHub issueHello! I use coverlet NuGet version 3.0.2
I have method marked as [ExcludeFromCodeCoverage], It’s async method. Some lines inside method skipped from excluding and are marked as uncovered, It’s on PrintScreen from report below code
`` [ExcludeFromCodeCoverage] public async Task<List<OrganizationStructureModel>> GetOrganizationStructureByPartnerAsync(Guid partnerId) { var topPartner = await _partnerService.GetTopPartnerAsync(partnerId);
var filials = await GetFilialsByBusinessUnits().Where(i=>i.NewDicFilialExtensionBase.NewPartnerId == topPartner.Id)
.ToListAsync();
var filialIds = filials.Select(i => i.NewDicFilialId).ToList();
var businessUnits = await _db.BusinessUnitBase.Include(i => i.BusinessUnitExtensionBase)
.In(filialIds, i=> i.BusinessUnitExtensionBase.NewFilialid.Value)
.ToListAsync();
return filials.Select(i => i.ToViewModel(businessUnits)).ToList();
}
``
And printscreen from coverage report
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
c# - Can I exclude part of a method from code coverage?
I know I can exclude a class or method from coverage analysis with the [ExcludeFromCodeCoverage] attribute, but is there a way to exclude...
Read more >How to exclude code from code coverage
What to exclude from code coverage? I think almost all applications have some classes we don't want to test. Usual candidates are primitive ......
Read more >ExcludeFromCodeCoverageAttri...
Specifies that the attributed code should be excluded from code coverage information. public ref class ExcludeFromCodeCoverageAttribute sealed : Attribute. C#
Read more >Ignore C# Code marked as ExcludeFromCodeCoverage from ...
So C# has the attribute [ExcludeFromCodeCoverage] to exclude this code from Coverage Analyse. Sa… ... danielhwe (Daniel Wehrle) September 28, 2022, 5:55am 1 ......
Read more >Customizing Code Coverage Analysis - Visual Studio
Learn how to use the ExcludeFromCodeCoverageAttribute attribute to exclude test code from coverage results. You can include assemblies ...
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
Hi all here,
at the moment coverlet try to follow the chain of caller(parent classes) in case
[ExludeFromCodeCoverage]
and also in my local test I’m not able to repro, looks like compiler does something new(organize types in a different way) and we need a simple repro to be able to fix this issue. You can find sample here https://github.com/coverlet-coverage/coverlet/tree/master/test/coverlet.core.tests/Samples ExcludeFromCoverage.IssueXXX@MarcoRossignoli - Does this work for an example?
In this code, the
GetClaimTypeValue
function has all statements being reported as uncovered. TheGetClaimValue
that is below it is properly excluded from the analysis.