-
Notifications
You must be signed in to change notification settings - Fork 247
Excludebyattribute not excluding the method #779
Comments
@sawilde Just checking in on this issue. Could you help with why the method isn't being skipped properly? |
Hi @dwkane - from your description, it is possibly due to it being an |
@sawilde Yes, after a bit of searching existing issues, I would guess it is related to the async. This would be great to be unblocked on as I am looking to reduce the amount of noise in the reports for methods that don't need coverage. Thanks. :) |
@dwkane I'll have a look but having issue with my build server at the moment :( |
@sawilde Just one more screenshot showing awaits being indicated as uncovered branches. It might be related to my issue. |
@dwkane OpenCover looks at IL branches and does its best to align them with source code - async/await may look simple to write but the IL produced it quite complex. If you want to diagnose it then you should start decompiling into IL and see if you can see the cause yourself. |
It should also come as no surprise that C#7.0 local functions are similarly not excluded even if the enclosing method is. |
Yup - it is slated for a future release |
Please provide the following information when submitting an issue.
My Framework
My Environment
I have already...
My issue is related to (check only those which apply):
Expected Behavior
I am expecting that when using an attribute on a method and then using the -excludebyattribute filter, that the entire method would be excluded from coverage reporting.
Actual Behavior
The line within the method is still reported as uncovered. See repro steps for details.
Steps to reproduce the problem:
OpenCover command:
"%userprofile%\.nuget\packages\OpenCover\4.6.801\tools\OpenCover.Console.exe" -oldstyle -output:"opencover.xml" -register:user -target:"powershell.exe" -targetargs:"C:\Sentinel\buildtest.ps1" -filter:"+[*]Sentinel.* -[Fake*]* -[Fluent*]*" -mergebyhash -skipautoprops -hideskipped:All -coverbytest:* -excludebyattribute:*.Exclude*
The buildtest.ps1 contains:
dotnet build
dotnet vstest (Get-ChildItem -recurse -File *.Tests.*dll | ? { $_.FullName -notmatch "\\obj\\?" })
Output XML attached as well:
opencover.zip
Method is: Sentinel.Registration.API\Sentinel.Registration\Sentinel.Registration.Api\Controllers\RegistrantController.cs:Get (as the example shown here)
If I don't use the exclude attribute, then line 44 in the image attachment is shown uncovered as well. This is considered a pass through method for us and we are saying it doesn't need unit test coverage (because the getRegistrantById class has it's own tests).
Here's an additional screenshot showing the Exclude attribute working for the constructor. You can see three methods here. Two with the Exclude attribute and one without. It correctly excludes the constructor. Is this an issue with delegates in a method?
How can we truly skip this method (and others like it)? In the output XML, I don't see any of the skippeddueto=Attribute things that would indicate that the method should be skipped.
I have reproduced this on the latest release (4.6.519) and the latest build (4.6.801).
Any ideas? Am I missing something?
The text was updated successfully, but these errors were encountered: