lucaslorentz/minicover

some method coverage not right

fs7744 opened this issue · 1 comments

  • problem :
    some method can't coverage by mincover , but the method has test in ut, i don't know
  • env:
    win10
  • ide:
    vs2017
  • example file:
    XUnitTestProject1.zip
  • example code :
public static class Class1
    {
        public static long? GetInt64WithNull(this IDataRecord record, int index)
        {
            return record.IsDBNull(index) ? (long?)null : record.GetInt64(index);
        }

        public static long? GetInt64WithNull(this IDataRecord record, string name)
        {
            return record.GetInt64WithNull(record.GetOrdinal(name));
        }
    }

[Fact]
        public void TesGetInt64WithIsDBNullCheck()
        {
            var reader = new ListDataReader<Student>(_Students);
            reader.Read();
            var col = "Long2";
            Assert.Equal(2, reader.GetInt64WithNull(col).Value);
            reader.Read();
            Assert.False(reader.GetInt64WithNull(col).HasValue);
            reader.Read();
            Assert.Equal(3, reader.GetInt64WithNull(col).Value);
        }

It is working fine with latest version 3.0.1. I did a lot of improvements in version 3.

Please, test again with your test project:

dotnet build
minicover instrument --sources "**/*.cs"
dotnet test --no-build
minicover htmlreport

HTML Coverage report:
coverage-html.zip