ternary coverage
Increase resolution of coverage so that a ternary expression shows code coverage if one branch is not covered. (Otherwise my team is going to make me always use 8-line ifs instead of 1-line ternaries just so we can see code coverage completely :'( )

-
Patrick Peters commented
This is called branch coverage. NCrunch currently only supports line coverage.
Because we use Sonar, we always get coverage differences because of Sonar's combined line/branch coverage method,
Coverage = (CT + CF + LC)/(2*B + EL)
where:CT = conditions that have been evaluated to 'true' at least once
CF = conditions that have been evaluated to 'false' at least once
LC = covered lines = linestocover - uncovered_lines
B = total number of conditions
EL = total number of executable lines (lines_to_cover)see https://docs.sonarqube.org/latest/user-guide/metric-definitions/
-
Ian Bowyer commented
I was going to add a sample code example but seeing that this is 7 years old with no feed back begs to see if anyone actually reads these and actions on them. Here's the example in case they do...
1. var result = await _exampleRepository.GetAsync(request.Id, cancellationToken);
2. return result ?? throw new NotFoundException(request.Id);Will show as green light if the happy path has a tested but no test on the NotFoundException
In Comparison the following shows no coverage on line 4
1. var result = await _exampleRepository.GetScreenAsync(request.Id, cancellationToken);
2. if (result == null)
3. {
4. throw new NotFoundException(request.Id);
5. } -
Anonymous commented
Same for test and body on same line.
if(false) return "notCoveredButMarkerIsGreen";
wallaby js use another color for patial cover