Branch coverage dropped 20%
See original GitHub issueHello,
I’ve been using the report generator for a few months now without any major hiccups until just recently. Something has changed on the branch coverage generation and I can’t make any sense of how to resolve it. My branch coverage has dropped from ~80% to ~60% without nearly that many changes being made to the code.
An example is this:

The message shows 2/4 branch coverage, but it is on the method opening bracket which makes no sense at all. Can anyone tell me how to address this because this appears to be where I have lost the big percentage.
The tests for the code shown above are as follows:
[Fact]
public async Task Delete_OkRequest_ReturnsJson()
{
// Arrange
_mockBlogService.Setup( s => s.Tags.GetByID( It.IsAny<int>() ) )
.ReturnsAsync( new Tag() );
_mockBlogService.Setup( s => s.Tags.Delete( It.IsAny<int>() ) )
.ReturnsAsync( HttpResponseHelper.GetHttpResponse( null, System.Net.HttpStatusCode.OK ) );
// Act / Assert
var result = Assert.IsType<JsonResult>( await _controller.Delete( new TagViewModel() ) );
}
[Fact]
public async Task Delete_BadRequest_ReturnsJson()
{
// Arrange
_mockBlogService.Setup( s => s.Tags.GetByID( It.IsAny<int>() ) )
.ReturnsAsync( new Tag() );
_mockBlogService.Setup( s => s.Tags.Delete( It.IsAny<int>() ) )
.ReturnsAsync( HttpResponseHelper.GetHttpResponse( null, System.Net.HttpStatusCode.BadRequest ) );
// Act / Assert
var result = Assert.IsType<JsonResult>( await _controller.Delete( new TagViewModel() ) );
}
[Fact]
public async Task Delete_ErrorOnAPI_ReturnsJson()
{
// Arrange
_mockBlogService.Setup( s => s.Tags.GetByID( It.IsAny<int>() ) )
.ThrowsAsync( new System.Exception() );
// Act / Assert
var result = Assert.IsType<JsonResult>( await _controller.Delete( new TagViewModel() ) );
}
Granted these are not thorough as far as checking the results, but they should still be hitting all branches.
Here are shots of the overall coverage drop:
BEFORE

AFTER

Thank you for any assistance.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)

Top Related StackOverflow Question
@MarcoRossignoli sure thing, I’ll see if I can make a simple repro on a new project, otherwise, I’ll try to provide as much detail as I can with what I have now.
I’m closing this issue since ReportGenerator parses the coverage file correctly.
The coverage file itself seems to be incorrect.