coverlet-coverage / coverlet

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

Is it possible to write exclusion expressions in a file and feed it to coverlet coverage counting? #1370

Open everwisher opened 1 year ago

everwisher commented 1 year ago

I just need to cherry-pick a bunch of classes and methods that are inappropriate for unit testing out of a big solution consisting of a number of projects. As these units are distributed to a lot of files, it would be ugly to attach a super long arguments to set them all out of the testing. So is there a way to create a file of certain format that allows input of the expressions via argument all at once?

MarcoRossignoli commented 1 year ago

We don't have that feature at the moment, isn't enough glob patterns like https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/MSBuildIntegration.md#source-files? I don't know if rsp file can be useful in this case https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-response-files?view=vs-2022

github-actions[bot] commented 10 months ago

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

Bertk commented 4 months ago

You can use a props file which should be imported for test projects.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <CollectCoverage Condition="$(CollectCoverage) == ''">false</CollectCoverage>
    <Include Condition="$(Include) == ''"></Include>
    <IncludeDirectory Condition="$(IncludeDirectory) == ''"></IncludeDirectory>
    <Exclude Condition="$(Exclude) == ''"></Exclude>
    <ExcludeByFile Condition="$(ExcludeByFile) == ''"></ExcludeByFile>
    <ExcludeByAttribute Condition="$(ExcludeByAttribute) == ''"></ExcludeByAttribute>
    <IncludeTestAssembly Condition="'$(IncludeTestAssembly)' == ''">false</IncludeTestAssembly>
    <SingleHit Condition="'$(SingleHit)' == ''">false</SingleHit>
    <MergeWith Condition="$(MergeWith) == ''"></MergeWith>
    <UseSourceLink Condition="$(UseSourceLink) == ''">false</UseSourceLink>
    <DeterministicReport Condition="$(DeterministicReport) == ''">false</DeterministicReport>
    <CoverletOutputFormat Condition="$(CoverletOutputFormat) == ''">json</CoverletOutputFormat>
    <CoverletOutput Condition="$(CoverletOutput) == ''">$([MSBuild]::EnsureTrailingSlash('$(MSBuildProjectDirectory)'))</CoverletOutput>
    <Threshold Condition="$(Threshold) == ''">0</Threshold>
    <ThresholdType Condition="$(ThresholdType) == ''">line,branch,method</ThresholdType>
    <ThresholdStat Condition="$(ThresholdStat) == ''">minimum</ThresholdStat>
    <ExcludeAssembliesWithoutSources Condition="$(ExcludeAssembliesWithoutSources) == ''"></ExcludeAssembliesWithoutSources>
  </PropertyGroup>
</Project>
github-actions[bot] commented 1 month ago

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