在Azure管道脚本中,剧作家测试失败,管道未切换到下一个脚本

gwbalxhn  于 2023-10-22  发布在  其他
关注(0)|答案(1)|浏览(93)

我的测试管道被拆分为多个脚本,每个脚本都有1到4个测试。当脚本通过管道开始执行下一个。但如果脚本失败,它会通知失败,不会继续,只是计算时间,直到代理作业停止
下面是管道yml:

# Node.js with React
# Build a Node.js project that uses React.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript


schedules:
- cron: "0 0 * * *"
  displayName: Daily midnight build
  branches:
    include:
    - master
  always: true

# variables:
#   CI: true

trigger:
- master

pool:
  name: Pool3

jobs:
- job: Test
  timeoutInMinutes: 180
  cancelTimeoutInMinutes: 2

  steps:
  - task: NodeTool@0
    inputs:
      versionSpec: '15.x'
    displayName: 'Install Node.js'
    condition: 

  - task: DownloadSecureFile@1
    inputs:
      secureFile: '.env'

  # - script: |
  #     npm ci
  #   displayName: "Install dependencies"

  - script: |
      npm install
      npx playwright install --with-deps
    displayName: "Install Playwright Browsers"

  - script: |
      npx playwright test 1.EndowmentTotalSurrenderAndClaimEventBank.spec.ts
    displayName: "Run 1.EndowmentTotalSurrenderAndClaimEventBank"

  - script: |
      npx playwright test 13.EndowmentPartialBank.spec.ts
    displayName: "Run 13.EndowmentPartialBank"

  - script: |
      npx playwright test 2.EdowmentTotalSurrenderAndClaimEventEnterOtherRequestTotal.spec.ts 6b.EndowmentClaimEventUnsettlement.spec.ts 7.EndowmentTotalSurrenderAndClaimEventBankOtherOutpayment.spec.ts 
    displayName: "Run EdowmentAndClaimEvent tests"

# 3.EndowmentTotalSurrenderAndClaimEventNetting.spec.ts 4.EndowmentClaimEventBankAndNetting.spec.ts

  - script: |
      npx playwright test 6a.EndowmentClaimEventBankCancelPayoutWithOutpaymentClaimWorkflow.spec.ts 11.EndowmentTotalSurrenderAndClaimEventBankCancelStateTaxes.spec.ts 
    displayName: "Run EndowmentCancel tests"

# 5.EndowmentClaimEventBankAndNettingCancel.spec.ts 12.EndowmentTotalSurrenderAndClaimEventNettingCancelStateTaxes.spec.ts

  - script: |
      npx playwright test 9.EndowmentTotalSurrenderAndClaimEventBankStateTaxes.spec.ts 
    displayName: "Run EndowmentTaxes tests"

# 10.EndowmentTotalSurrenderAndClaimEventNettingStateTaxes.spec.ts

  - script: |
      npx playwright test 8.Non-insuredClaimEvent.spec.ts 14.EndowmentTotalBank.spec.ts 15.EndowmentPolicyTermiantionPayoutTotalApproved.spec.ts
    displayName: "Run EndowmentOthers tests"

  - script: |
      npx playwright test 16.ManualPayableOutpaymentGroup.spec.ts 17.ManualPayableOutpaymentSplit.spec.ts 18.ManualPayableOutpaymentBank.spec.ts 19.ManualPayableOutpaymentOther.spec.ts 20.ManualPayableOutpaymentCanceled.spec.ts 
    displayName: "Run ManualBank tests"   
    
  - script: |
      npx playwright test 22.RefundCoverUncover.spec.ts 23.RefundGroup.spec.ts 24.RefundOtherOutpayment.spec.ts 25.RefundNetting.spec.ts
    displayName: "Run Refund tests"

  - script: |
      npx playwright test 21.ManualNetting.spec.ts 26.ManualNettingRemove.spec.ts 27.ManualPayableOutpaymentSplitBank.spec.ts 28.ManualPayableOutpaymentSplitUnsplit.spec.ts
    displayName: "Run ManualNetting tests"

以下是结果截图:enter image description here
然后所有测试都在一个脚本中通过,它成功地关闭并返回通过/失败的测试。yml文件有问题吗?

8ftvxx2r

8ftvxx2r1#

只需尝试在管道中启用变量CI=true即可。
在运行测试之前,也可以添加“set CI=true“。

- script: |
      set CI=true && npx playwright test 22.RefundCoverUncover.spec.ts 23.RefundGroup.spec.ts 24.RefundOtherOutpayment.spec.ts 25.RefundNetting.spec.ts
    displayName: "Run Refund tests"

更新:

在您的场景中,如果一个测试脚本在一个步骤中失败,那么它将跳过下一个脚本,该步骤将失败。并且该流水线将被认为是失败的,所以接下来的步骤也将被跳过,流水线将被跳到最后。
如果您想运行管道中的所有测试脚本,您可以将测试脚本分割成单独的步骤(一个步骤一个脚本)。然后为每个步骤任务设置continueOnError: true。因此,即使前一个测试步骤失败,它也会继续进行下一步。
举例来说:

- script: | 
      set CI=true && npx playwright test 22.RefundCoverUncover.spec.ts 
    displayName: "Run Refund test22"
    continueOnError: true

  - script: |
      set CI=true && npx playwright test 23.RefundGroup.spec.ts 
    displayName: "Run Refund test23"
    continueOnError: true

  - script: |
      set CI=true && npx playwright test 24.RefundOtherOutpayment.spec.ts
    displayName: "Run Refund test24"
    continueOnError: true
  
  - script: |
      set CI=true && npx playwright test 25.RefundNetting.spec.ts
    displayName: "Run Refund test25"
    continueOnError: true

相关问题