Coverlet and Case-Sensitivity

If you are familiar with Linux, you already know that one of its differences from Windows is file systems case-sensitivity. Dev teams have to ensure casing is correct for building and testing on Linux; then Windows generally works.

As we containerize .NET Core code to run on Linux as well as Windows, we have encountered some interesting case-sensitivity issues. Recently, we realized that the open source code coverage tool for .NET Core, Coverlet, is always case-sensitive – even on Windows – with the Include parameter. Consider the following dotnet command:

dotnet test /p:CollectCoverage=true /p:Include="[J3DI*]*" /p:Exclude="[Test.J3DI*]*"  ./Test.J3DI.Domain

This command works correctly because the casing matches the path and file names on both OSs. (Cloning the Git repository, on either Linux or Windows, retains file and path casing.)

If we change the command just slightly (change Include filter specification to lower-case ‘i’):

dotnet test /p:CollectCoverage=true /p:Include="[J3Di*]*" /p:Exclude="[Test.J3DI*]*"  ./Test.J3DI.Domain

The tests run, but no code coverage will be recorded. Coverlet will output the standard coverage.json file, but it only contains an empty object. The file size is very small (just 2 in my case). Worse, Coverlet will report 100% coverage – very misleading.

| Module | Line | Branch | Method |

|         | Line | Branch | Method |
| Total   | 100% | 100%   | 100%   |
| Average | NaN% | NaN%   | NaN%   |

To remedy, double check casing in the file paths and Include / Exclude filters.

This site uses Akismet to reduce spam. Learn how your comment data is processed.