You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered this with stable coverlet.collector as well as nightly 3.0.4-preview.31.g4902c245c8. I'm using .NET SDK 5.0.300 and running dotnet test --collect:"XPlat Code Coverage".
This code has 3 out of 6 blocks covered despite having no branches apart from awaits. Removing or reordering any of the statements results in 100% coverage and cyclomatic complexity of 1 instead of 6. I would expect this code to also have cyclomatic complexity of 1 and to be fully covered.
using System.IO;using System.Threading.Tasks;namespaceLib{publicclassFoo{publicstaticasync Task Bar(){await Task.CompletedTask;usingvar_=new MemoryStream();await Task.CompletedTask;await Task.CompletedTask;await Task.CompletedTask;}}}
The report shows the using statement has 1 of 4 branches covered.
using System.Threading.Tasks;using Xunit;namespaceTest{publicclassFooTest{[Fact]publicasync Task Test(){await Lib.Foo.Bar();}}}
The text was updated successfully, but these errors were encountered:
strout
changed the title
Unexpected branch coverage with using statement and several awaits.
Unexpected branch coverage with using statement and several awaits
Jun 8, 2021
I've encountered this with stable coverlet.collector as well as nightly 3.0.4-preview.31.g4902c245c8. I'm using .NET SDK 5.0.300 and running
dotnet test --collect:"XPlat Code Coverage"
.This code has 3 out of 6 blocks covered despite having no branches apart from awaits. Removing or reordering any of the statements results in 100% coverage and cyclomatic complexity of 1 instead of 6. I would expect this code to also have cyclomatic complexity of 1 and to be fully covered.
The report shows the using statement has 1 of 4 branches covered.
I used this test class.
The text was updated successfully, but these errors were encountered: