Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

asp.net rest api .net 6, code coverage for Program.cs?
GreenMoose
#1 Posted : Wednesday, April 13, 2022 5:28:47 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 507

Thanks: 145 times
Was thanked: 66 time(s) in 64 post(s)
[v4.11.0.2]

Hi, when using the .net 6 vs2002 template for web api, the last line seems never to be covered.
My goal is to have 100% coverage (ideally with the [ExcludeFromCodeCoverage] attribute if needed), but am a bit puzzled of how to achieve this in the new rest api design.

Any hints of how I can achieve this?

Thanks!
screenshot
Remco
#2 Posted : Thursday, April 14, 2022 12:03:37 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,161

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi, thanks for posting.

When the analyse line execution times setting is enabled (which is on by default), NCrunch marks a line as covered after it is executed. This means that if the call never returns during the test run, the line of code doesn't complete, and NCrunch doesn't mark it as covered.

If you disable the setting, the line should be marked as covered, as NCrunch won't need to collect the wall time for the method call so there is no need to mark the coverage after it's been executed.

You could say that this is a technical limitation caused by the need to track the time spent executing the line of code. If the line never finishes, how do you track its time?
1 user thanked Remco for this useful post.
GreenMoose on 10/27/2022(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.023 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download