25

I committed the changes to the pull request and yt shows

"Code coverage status failed.".

I have searched a lot, but couldn't find the cause or solution to resolve this.

Azure pipeline test service 
Diff coverage check failed.0/70 (0.00 %) changed lines are covered up to update 2. Diff coverage target is 70.00 %. 

Verification build is successful but the status is showing code coverage has failed.

riQQ
  • 9,878
  • 7
  • 49
  • 66
prasanthi
  • 562
  • 1
  • 9
  • 25
  • 1
    possible same issue [here](https://stackoverflow.com/questions/57211986/schema-for-azurepipelines-coverage-yml-to-configure-newly-released-code-coverage) on stack? – Mar Tin Jul 26 '19 at 08:18

3 Answers3

13

Create an azurepipelines-coverage.yml config file at the root of your repo with any of the following:

coverage:
  status: off     #default on

Turning this off will not post any coverage checks and coverage annotations will not appear in the changed files view.


coverage:
  status:
    diff:
      target: 30%     default 70%

Target threshold value for diff coverage must be met for a successful coverage status to be posted.


coverage:
  status:
    comments: on    #default off

Indicates whether a comment containing coverage details for each code file should be posted in the pull request


Microsoft Docs; Configuring coverage settings

ArtiomLK
  • 2,120
  • 20
  • 24
  • How is this doable for the old school UI version of the builds? We have turned the condition off, yet it still reports the error on PRs. – one.beat.consumer Jun 01 '22 at 18:01
2

Desired coverage thresholds can be defined in an azurepipelines-coverage.yml settings file that is checked in at the root of the repo:

coverage:
  status:
    diff:
      target: 40%
starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • Is this file covered anywhere in the Azure Pipelines documentation? – Philip Pittle Jul 27 '19 at 21:27
  • @PhilipPittle Seems no. – starian chen-MSFT Jul 29 '19 at 11:20
  • Hi @starianchen-MSFT, Thanks for reply to my question. Actually i need to know why it is shown in my pull request. I didn't add any configuration as status to my pull request However it shown.Is any recent release(ON july 22 nd) included auto adding of status in pull request?.Azure pipeline test service is shown based on status in pull request or any other? – prasanthi Jul 31 '19 at 07:08
  • 1
    @prasanthi It is the new feature https://learn.microsoft.com/en-us/azure/devops/release-notes/2019/sprint-155-update#code-coverage-metrics-and-branch-policy-for-pull-requests. But seems that there isn't a way to disable it. – starian chen-MSFT Jul 31 '19 at 08:19
  • @starianchen-MSFT any update on when documentation for that file will be made available? – pinkfloydx33 Jul 31 '19 at 15:49
  • Hi @starianchen-MSFT, Thanks for reply. But i got this configuration status add to only one repostiory pull request . I doesn't added to remaining repository pull request.May i know the reason – prasanthi Aug 01 '19 at 06:56
  • @prasanthi Is there code coverage result in the related build? – starian chen-MSFT Aug 01 '19 at 07:00
  • @starianchen-MSFT yes code coverage is added in build. – prasanthi Aug 05 '19 at 09:02
  • 1
    @prasanthi Do you mean there isn't code coverage analysis result in pull request even through there is build (branch policy) has code coverage result? – starian chen-MSFT Aug 05 '19 at 11:30
  • 4
    The annoying this about this new service is that it includes the Test projects themselves in the results (saying that they are not covered), even if adding an `[assembly: ExcludeFromCodeCoverage]` to the project. It would be really nice if we had a way to exclude or use our own RunSettings/Coverage setup. Maybe we do.... but nothing is documented.. @starianchen-MSFT any update on where the schema is for this file? – pinkfloydx33 Aug 05 '19 at 12:45
  • @pinkfloydx33 There is no schema now. – starian chen-MSFT Aug 05 '19 at 13:56
  • @starianchen-MSFT could you explain what your example means? Does it mean the difference between the last coverage? Or is "diff" a misnomer? – pinkfloydx33 Aug 05 '19 at 14:06
  • 1
    @pinkfloydx33 I think it is based on the last merged version. – starian chen-MSFT Aug 05 '19 at 14:20
  • @pinkfloydx33, it appears that you can exclude assemblies. https://learn.microsoft.com/en-us/visualstudio/test/customizing-code-coverage-analysis?view=vs-2022 – Captain America May 05 '23 at 19:11
-2

As other people have mentioned you can configure the coverage status check via azurepipelines-coverage.yml file. Full schema is available here.

Nano
  • 25
  • 1