-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Excluded method is still included in the coverage report #1389
Comments
Thanks for reporting this. |
Found a relevant stackoverflow: https://stackoverflow.com/questions/72487078/c-sharp-exclude-lambda-expression-from-code-coverage/72487708#72487708. Seems like coverlet is unable to trace the lambda function back to the function that contains it. |
@daveMueller What does |
@Nodnarb3 I don't really think so. At least I can't remember a bugfix for an issue like that in the last release. Could you tell me how you build the assemblies under test? Do you maybe have a |
Projects are being built as follows, with BuildConfiguration set to ...
# Build all projects and don't allow warnings
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
command: build
projects: '**/*.csproj'
arguments: '/warnaserror --configuration $(BuildConfiguration)'
# Test all projects and collect coverage results
- task: DotNetCoreCLI@2
displayName: 'dotnet test'
inputs:
command: 'test'
projects: '${{ parameters.testGlob }}'
arguments: '--configuration $(BuildConfiguration) --settings ./server/coverlet.runsettings --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura'
... coverlet.runsettings: <?xml version="1.0" encoding="utf-8"?>
<!-- File name extension must be .runsettings -->
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat Code Coverage">
<Configuration>
<ExcludeByFile>**/Migrations/*.cs</ExcludeByFile>
<SingleHit>True</SingleHit>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings> |
Thanks @Nodnarb3, nothing really out of the ordinary. Unfortunately I still can't reproduce it. |
This issue is stale because it has been open for 3 months with no activity. |
This issue was closed because it has been inactive for 9 months since being marked as stale. |
I think there is a regression from #849 bug fix. We are using coverlet 3.1.2 running on .net 6. There is a method declared like this:
When running unit tests and collecting coverage report, this method is still included in the report. Here is the relevant portion of the coverage report in different formats:
Line 167 is the
await database.ScriptEvaluateAsync
line from that method. Somehow that single line is declared as "not covered" instead of being excluded with the rest of the method.It might have something to do with this line being async lambda which complies into a more complicated state machine.
The text was updated successfully, but these errors were encountered: