-
Notifications
You must be signed in to change notification settings - Fork 390
Closed
Labels
tenet-coverageIssue related to possible incorrect coverageIssue related to possible incorrect coverage
Description
Hello
In the following code the await foreach
as well as the for
and the yield
statements are marked as partially covered due to the hidden async/await logic of the compiler. Can this be reported as covered by coverlet?
Reproduction class:
public class AwaitForeachReproduction
{
public async Task<int> Execute()
{
int sum = 0;
await foreach (int result in AsyncEnumerable())
{
sum += result;
}
return sum;
}
private async IAsyncEnumerable<int> AsyncEnumerable()
{
for(int i = 0; i < 100; i++)
{
await Task.Delay(10);
yield return i;
}
}
}
Test Case for it:
public class AwaitForeachReproductionFixture
{
[Fact]
public async Task Execute_ShouldWork()
{
// Arrange
var sut = new AwaitForeachReproduction();
// Act
int result = await sut.Execute();
// Assert
Assert.Equal(4950, result);
}
}
Coverlet version: 3.0.3
Metadata
Metadata
Assignees
Labels
tenet-coverageIssue related to possible incorrect coverageIssue related to possible incorrect coverage