False positive branch coverage
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 66/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- csharp
- Domain
- testing-qa
Research direction
Start with MicrosoftCoverageTest.zip and run the shown dotnet test command against Class1.Test1. Compare the generated Cobertura report with the single executed path in the test; done means the report no longer marks both branch outcomes as covered for this reproduction.
Written by the indexing model from the issue text.
Description
Class under test
namespace CoverageTest;
public static class Class1
{
public static int Test1(int n)
{
if (n < 10)
n = Random.Shared.Next();
return n;
}
}
Test class
using Xunit;
namespace CoverageTest.Tests;
public static class Class1Tests
{
[Fact]
public static void Test1()
{
Class1.Test1(2);
}
}
Command executed
dotnet test -verbosity:diagnostic -c Debug --collect:"Code Coverage;IncludeTestAssembly=False;Format=cobertura;CoverageFileName=R:\coverage\CoverageTest.Tests\cobertura.xml"
Excerpt from coverage results
<method line-rate="1" branch-rate="1" complexity="2" name="Test1" signature="(int)">
<lines>
<line number="6" hits="1" branch="False" />
<line number="7" hits="1" branch="True" condition-coverage="100% (2/2)">
<conditions>
<condition number="0" type="jump" coverage="100%" />
</conditions>
</line>
<line number="8" hits="1" branch="False" />
<line number="9" hits="1" branch="False" />
<line number="10" hits="1" branch="False" />
</lines>
</method>
The branch is executed only once, so it should not be possible to have coverage of both sides of the branch (taken and not-taken).
- Dominant language
- C#
- Stars
- 125
- Forks
- 17
- Avg merge
- 1h 17m
- Merged PRs (30d)
- 2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/codecoverage
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
microsoft/codecoverage#246 · 6 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
microsoft/codecoverage#237 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
microsoft/codecoverage#234 · 1 comment · 2 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
microsoft/codecoverage#233 · 2 reactions ·
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
microsoft/codecoverage#232 · 6 comments ·
All issues in microsoft/codecoverage
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·