coverlet icon indicating copy to clipboard operation
coverlet copied to clipboard

Exclude by Base class \ Interface?

Open gdoron opened this issue 2 years ago • 3 comments

We have many projects with EF migrations and no one is using the Down Method to revert a migration, so we don't care of covering it with UTs.

Ideally it would be best to exclude only the Down method, but assuming that is impossible without decorating each method with [ExcludeFromCodeCoverage], we would like to ignore all classes deriving from the BaseClass Microsoft.EntityFrameworkCore.Migrations.Migration.

Is it possible with coverlet?

gdoron avatar Dec 02 '22 11:12 gdoron

It's not possible now, but for migrations specifically you can try to use Exclude to exclude them by the namespace they end up in, or ExcludeByFile by the directory: https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/MSBuildIntegration.md#excluding-from-coverage

petli avatar Dec 02 '22 11:12 petli

Yes, this what we ended up doing: <ExcludeByFile>**/*.DataAccess/*Migrations/*.cs,... I was wondering if there is a better and more explicit way for that (and hopefully only ignore specific a method though assumed this one is impossible).

gdoron avatar Dec 02 '22 11:12 gdoron

This issue is stale because it has been open for 3 months with no activity.

github-actions[bot] avatar Nov 26 '23 01:11 github-actions[bot]

Yes, this what we ended up doing: <ExcludeByFile>**/*.DataAccess/*Migrations/*.cs,... I was wondering if there is a better and more explicit way for that (and hopefully only ignore specific a method though assumed this one is impossible).

Solution available. Issue closed.

Bertk avatar Jul 21 '24 08:07 Bertk