## Class under test ```C# namespace CoverageTest; public static class Class1 { public static int Test1(int n) { if (n < 10) n = Random.Shared.Next(); return n; } } ``` ## Test class ```C# 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 ```XML <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). [MicrosoftCoverageTest.zip](https://github.com/user-attachments/files/26989001/MicrosoftCoverageTest.zip)
Activity