coverlet-coverage / coverlet

Cross platform code coverage for .NET
MIT License
2.98k stars 386 forks source link

Not correct conditions coverage #1182

Open jakubch1 opened 3 years ago

jakubch1 commented 3 years ago

Hi, I've run coverlet on such method

        public void OtherMethod()
        {
            int i = 0;
            if ( i < 10 || i < 2 )
            {
                Console.WriteLine("lallaa");
            }
        }

and coverage is:

            <line number="21" hits="1" branch="True" condition-coverage="75% (3/4)">
              <conditions>
                <condition number="6" type="jump" coverage="50%" />
                <condition number="17" type="jump" coverage="100%" />
              </conditions>
            </line>

probably it should be:

            <line number="21" hits="1" branch="True" condition-coverage="25% (1/4)">
              <conditions>
                <condition number="6" type="jump" coverage="50%" />
                <condition number="17" type="jump" coverage="0%" />
              </conditions>
            </line>

as second condition is not even checked. This is more a question if using mono.cecil are you able to calculate it correctly?

MarcoRossignoli commented 3 years ago

Thanks for reporting this

Bertk commented 2 weeks ago

Please verify whether the problem still exists using the latest coverlet 6.0.2 release.