I am trying to run unit tests using NUnit and coverlet but exclude assemblies that end with the name .Testing
from the coverage report. However, whatever I do the file (for example MyProj.Testing.dll
) is being added in the coverage report (other assemblies I don't want in the report, such as test assemblies, are not present).
I am using the following coverlet packages in my test assemblies:
coverlet.msbuild 3.2.0
coverlet.collector 3.2.0
I am using a .runsettings
file to configure coverlet.
coverlet.runsettings
file:
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<RunConfiguration>
<ResultsDirectory>./CodeCoverage/</ResultsDirectory>
</RunConfiguration>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat Code Coverage">
<Configuration>
<Format>cobertura</Format>
<ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute,TestSDKAutoGeneratedCode</ExcludeByAttribute>
<IncludeTestAssembly>false</IncludeTestAssembly>
<CodeCoverage>
<ModulePaths>
<Include>
<ModulePath>.*\.dll$</ModulePath>
<ModulePath>.*\.exe$</ModulePath>
</Include>
<Exclude>
<ModulePath>.*Testing\.dll$</ModulePath>
</Exclude>
</ModulePaths>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
I have looked at:
- How to exclude Projects with names ending in ".Test" from my code coverage analysis in VS2012 Unit Tests
- Using .runsettings to exclude assemblies from code coverage
- https://learn.microsoft.com/en-gb/previous-versions/visualstudio/visual-studio-2015/test/customizing-code-coverage-analysis?view=vs-2015&redirectedfrom=MSDN&viewFallbackFrom=vs-2017
I have also tried:
- Removing the Include section
- Setting the Exclude/ModulePath to:
.*Testing.*
- Using Sources/Exclude/Source instead of ModulePath
I have been trying to do this seemingly trivial thing for hours but am now out of ideas. Any help would be appreciated.