question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

0% branch coverage when code has no branches

See original GitHub issue

Hi,

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:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
samajscommented, May 9, 2019

@MarcoRossignoli my bad, just realised I am using coverlet.msbuild 2.0.1 but latest is 2.6.1, this one is fixed there. Thanks for pointing out 😃

0reactions
MarcoRossignolicommented, May 8, 2019

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found