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

Notification

Icon
Error

Coverage not detected
kentcb
#1 Posted : Wednesday, February 1, 2017 2:31:57 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/10/2016(UTC)
Posts: 20
Location: Australia

Thanks: 5 times
Was thanked: 2 time(s) in 2 post(s)
Hi,

I'm running 3.3.0.6 in VS2015.

I have a SUT that NCrunch is reporting as not fully covered. 2 out of 5 properties on the SUT are shown as covered, the other 3 uncovered. But I do have tests covering all properties and have verified those tests are running (and reset the execution engine to be sure).

Here's an example of a test that is _not_ detecting as covering the PhotoUri property:

Code:

[Theory]
[InlineData(null)]
[InlineData("")]
[InlineData("foo")]
[InlineData("bar")]
public void photo_uri_reflects_campus(string photoUri)
{
var campus = new CampusMockBuilder()
.WithPhotoUri(photoUri)
.Build();
var sut = new CampusViewModelBuilder()
.WithCampus(campus)
.Build();

Assert.Equal(photoUri, sut.PhotoUri);
}


But if I add this test the PhotoUri property _is_ detected as covered (but only by a single test):

Code:

[Fact]
public void foo()
{
var sut = new CampusViewModelBuilder()
.Build();

Assert.Null(sut.PhotoUri);
}


On a hunch, I tried changing it to a theory (suspicious that theories weren't contributing to coverage statistics):

Code:

[Theory]
[InlineData(1)]
public void foo(int whatever)
{
var sut = new CampusViewModelBuilder()
.Build();

Assert.Null(sut.PhotoUri);
}


But this _still_ reported PhotoUri as covered (again, by this single test).

I then removed the foo test and tried commenting out [InlineData("")] in the original test, letting tests run, then uncommenting it. Sure enough, this time the engine picked it up and shows it as covered.

What would cause this?

Thanks

PS. gods bbcode is super painful
Remco
#2 Posted : Wednesday, February 1, 2017 2:51:06 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 sharing this problem.

I've tried to construct a small reconstruction of this, but it's hard to understand how the pieces here connect without the actual code behind this.

A few things worth checking:

- Try running the test with a debugger to see which lines it actually hits. NCrunch records its coverage through which lines are physically touched by .NET while it executes as defined in the PDB, so this is a good way to check whether your code is behaving the way you expect it to.
- Try examining the code coverage for ONLY those tests that you would expect to touch the properties (i.e. right click on them and choose the show coverage only option). Examine the physical trace path of the test. Does this match your expectation of the code?

If you think this is a problem with NCrunch misreporting something, you are most welcome to build a reproduceable code sample that compiles independently and submit it through https://www.ncrunch.net/support/contact and I'll examine it in more detail.
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