Kevin YANG
Kevin YANG

Reputation: 441

Can run a build pipeline failed when the code coverage below a certain parameter

I added a .net test build to run my unit test

steps:
- task: DotNetCoreCLI@2
  displayName: 'Test Public API Project '
  inputs:
    command: test
    projects: '**/DWP.CDA.API.Test.csproj'
    arguments: '--output publish_output --configuration $(BuildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Threshold=80 /p:ThresholdStat=total /p:CoverletOutput=$(Build.SourcesDirectory)\TestResults\Coverage\ --collect "Code coverage"'

How can I get a build pipeline failed when code line coverage below 80%?

Upvotes: 0

Views: 2263

Answers (1)

Eric Smith
Eric Smith

Reputation: 2560

One option is to use the Build Quality Checks task. You can fail a build based on a number of different Code Coverage result options

Another path is that you could do something custom by getting the code coverage results from the rest API.

Upvotes: 1

Related Questions