Closed manuel-rw closed 6 months ago
Sorry for the late response. Even tho' you marked your Throw
method with the DoesNotReturnAttribute
, you still need to tell coverlet that statements after this method call should be excluded from coverage (methods-that-do-not-return).
Thus you just need to add this parameter to your test execution:
/p:DoesNotReturnAttribute="DoesNotReturnAttribute"
The complete call in your repro then will look like this:
dotnet test .\CoverletReproductions.sln --no-build --no-restore --configuration release --logger:trx -v minimal /p:DoesNotReturnAttribute="DoesNotReturnAttribute" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
which results in a 100% coverage.
I will close this as it is as-design and a duplicate of this #1265. @manuel-rw feel free to reopen if it doesn't help.
Describe the bug After throwing an exception via a method the method ending
}
is not being marked as covered.To Reproduce
https://github.com/meggima/coverlet-reproductions/pull/5
Expected behavior All four lines are fully covered.
Actual behavior Last line is marked as not covered:
Configuration (please complete the following information): Please provide more information on your .NET configuration:
coverlet.msbuild 3.1.2
(also triedcoverlet.msbuild 6.0.
).net 6
Windows 10, 22H2
x64
not specific
Additional context Add any other context about the problem here.