0% branch coverage when code has no branches
See original GitHub issueHi,
Small issue I noticed while playing around with Coverlet is that for code with no branches, 0% branch coverage is reported instead of 100%.
ConsoleApp1.csproj Program.cs
using System;
namespace ConsoleApp1
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
ConsoleApp1.Tests.csproj UnitTest1.cs
using System;
using Xunit;
namespace ConsoleApp1.Tests
{
public class UnitTest1
{
[Fact]
public void Test1()
{
Program.Main(new string[] { });
}
}
}
Output
Test run for C:\src\ConsoleApp1\ConsoleApp1.Tests\bin\Debug\netcoreapp2.1\Consol
eApp1.Tests.dll(.NETCoreApp,Version=v2.1)
Microsoft (R) Test Execution Command Line Tool Version 15.9.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 1.7762 Seconds
Calculating coverage result...
Generating report 'C:\src\ConsoleApp1\ConsoleApp1.Tests\coverage.opencover.xml
'
+-------------+--------+--------+--------+
| Module | Line | Branch | Method |
+-------------+--------+--------+--------+
| ConsoleApp1 | 100% | 0% | 100% |
+-------------+--------+--------+--------+
Total Line: 100%
Total Branch: 0%
Total Method: 100%
Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
0% branch coverage when code has no branches #261
Hi,. Small issue I noticed while playing around with Coverlet is that for code with no branches, 0% branch coverage is reported instead...
Read more >Why "Branch" test coverage in Jest shows 0% coverage?
1 Answer. Looks like 0% means you missed testing all if s that are definitely goes to the category Branch .
Read more >I'm getting 0% branch coverage on code with no branch logic.
I'm getting 0% branch coverage on code with no branch logic. It's a package that just contains JPA classes and Spring Controller Templates...
Read more >What Is Branch Coverage and What Does It Really Tell You?
Branch coverage is a metric that indicates whether all branches in a codebase are exercised by tests. A “branch” is one of the...
Read more >What's a Branch and How to Make Sure It's Covered
A branch is a piece of code that comes after a condition. In a branch, only one ... Denominator B can't be 0...
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
@MarcoRossignoli my bad, just realised I am using
coverlet.msbuild 2.0.1
but latest is2.6.1
, this one is fixed there. Thanks for pointing out 😃This PR fix the issue https://github.com/tonerdo/coverlet/pull/267 and last days we simplify more with rounding https://github.com/tonerdo/coverlet/pull/397