-
Notifications
You must be signed in to change notification settings - Fork 391
Closed
Labels
bugSomething isn't workingSomething isn't workingtenet-coverageIssue related to possible incorrect coverageIssue related to possible incorrect coveragewith reproIssue with reproIssue with repro
Description
Hi.
Using coverlet.msbuild.3.1.2, I noticed an issue with code coverage for a method which returns IAsyncEnumerable, as soon as the method is inside a generic class.
Here's a short example which reproduces the issue:
public class A
{
public static async IAsyncEnumerable<int> Demo()
{
yield return 5;
yield return 2;
}
}
public class A<T>
{
public static async IAsyncEnumerable<int> Demo()
{
yield return 5;
yield return 2;
}
}Given the following tests:
[Fact] public async Task Test1() => Assert.Equal(new [] { 5, 2 }, await A.Demo().ToListAsync());
[Fact] public async Task Test2() => Assert.Equal(new [] { 5, 2 }, await A<string>.Demo().ToListAsync());the coverage report will show that the Demo method inside the class A has 100% branch coverage, whereas the method Demo inside A<T> has only partial coverage (one branch out of two) on the line {, as well as on the following two yield return lines.
The code of the two methods and the corresponding tests being identical, the coverage should instead be identical, that is, 100% in both cases.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtenet-coverageIssue related to possible incorrect coverageIssue related to possible incorrect coveragewith reproIssue with reproIssue with repro