Coverlet doesn't track coverage of method with a LINQ query in an if statement
See original GitHub issueWhen a method has a LINQ query in an if
:
public async Task<IAccessResponse> CreateAsync(DocumentEntity entity)
{
var list = new List<DocumentEntity> { new DocumentEntity { id = "1" }, new DocumentEntity { id = "2" } };
if (list.Count(l => l.id == "1") > 1)
throw new Exception();
return new AccessResponse();
}
We get a result in the code coverage, that looks something like this:
But if we extract the query to a variable, it seems to work fine:
Seems like the issue is reproducible in coverlet.msbuild versions 2.7.0 and 2.8.0. Version 2.6.3 works fine.
Issue Analytics
- State:
- Created 4 years ago
- Comments:13
Top Results From Across the Web
Coverlet doesn't track coverage of method with a LINQ ...
It seems to be the combination of IEnumerable<> and the async state engine that causes coverlet to ignore all lines except the if/foreach...
Read more >LINQ `Any` not covered by unit test
1 Answer. I suspect the issue is that you are not testing all possible execution paths for the Any . You may need...
Read more >Measuring .NET Core Test Coverage with Coverlet
I love working with .NET Core on the command line (CLI) and Visual Studio Code. Until recently getting code coverage metrics for your...
Read more >Complex Query Operators - EF Core
Language Integrated Query (LINQ) contains many complex operators, which combine multiple data sources or does complex processing.
Read more >What's New in NDepend
Support for Properties and Events. The NDepend code model is now filled with properties and events thanks to the new interfaces IProperty and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can repro with @petli repro https://github.com/coverlet-coverage/coverlet/issues/760#issuecomment-644265756 At the moment don’t know it’s the same issue of other.
Glad to hear that, thanks for the test!