I'm trying to exclude a folder from the code coverage analysis, but I'm not having any luck despite a lot of trial and error and research on this site.
This is my build pipeline test task:
- task: DotNetCoreCLI@2
displayName: 'Running Unit Tests'
inputs:
command: test
projects: '$(unitTestsProject)'
arguments: '--configuration $(buildConfiguration) --settings ./cover.runsettings'
publishTestResults: true
continueOnError: false
and in the run settings I have tried different approaches, some of them are as bellow:*
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*Migrations.*</ModulePath>
<ModulePath>.*\\Migrations\\.*</ModulePath>
</Exclude>
</ModulePaths>
</CodeCoverage>
</Configuration>
</DataCollector>
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<CodeCoverage>
<ExcludeDirectories>
<Directory>.*\\Migrations\\.*</Directory>
</ExcludeDirectories>
</CodeCoverage>
</Configuration>
</DataCollector>
All of the above variations did not work.
But it worked well when I used the attribute [ExcludeFromCodeCoverage] on each class I didn't want included in the code coverage.
I need it to work from the runsettings file because the migrations folder will quickly grow and it's impractical to go through the generated classes and add attributes.
Any assistance or advice will be greatly appreciated.
Thank you very much.