Azure DevOps Build Pipeline - Exclude a Folder from Code Coverage

0 votes

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.

Dec 19, 2022 in DevOps on Cloud by Damonlang
• 1,230 points
3,396 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In DevOps on Cloud

0 votes
0 answers
0 votes
0 answers

Azure devops pipeline variable for a task step name

Is a variable available for the name of an Azure devops pipeline task step, as highlighted below? image from the pipeline I went over the predefined variables at https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=classic  However, ...READ MORE

Jan 5, 2023 in DevOps on Cloud by Damonlang
• 1,230 points
725 views
0 votes
1 answer

I am looking for a python code to get my Azure VM status in my email , like whether the running vms port is open to the internet. If its open to internet I should get a mail notification

Hey, @Sourav, Check this out https://www.edureka.co/community/66025/azure-vm-monitoring It deals with ...READ MORE

answered May 29, 2020 in DevOps on Cloud by Sirajul
• 59,230 points
1,673 views
0 votes
1 answer

How can we publish html test reports in azure devops build results?

This might help you. Have a look ...READ MORE

answered Oct 12, 2020 in DevOps on Cloud by Kriti

edited Oct 27, 2021 by Sarfaraz 8,756 views
0 votes
1 answer
0 votes
0 answers

Basic Azure DevOps flow for ASP .Net

I have a custom build script and ...READ MORE

Apr 20, 2022 in Other DevOps Questions by Kichu
• 19,050 points
431 views
0 votes
0 answers
0 votes
1 answer

powerbi embeded in .net core 1.1

See if it helps: https://www.nuget.org/packages/PowerBI.NetStandar ...READ MORE

answered Nov 28, 2018 in Power BI by Upasana
• 8,620 points
1,409 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP