gpt4 book ai didi

azure - 自动化测试在 Azure 中失败,但该步骤的结果是通过,这是为什么?

转载 作者:行者123 更新时间:2023-12-02 07:51:35 24 4
gpt4 key购买 nike

我有一套在代码提交时执行的自动化 API 测试。自动化测试运行,但其中许多测试按预期失败。但是,执行测试的步骤会成功返回。因此,整个作业都会成功,这是不正确的行为。

The failed tests but passed step and job

parameters:
- name: testScriptDisplayName
type: string
- name: testScript
type: string

trigger:
branches:
include:
- main

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

- script: |
ls -a
displayName: 'Explore output directory'
workingDirectory: '$(Build.Repository.LocalPath)/API/API-Tests'

- script: |
npm install
npx playwright install --with-deps
displayName: "npm install"
workingDirectory: '$(Build.Repository.LocalPath)/API/API-Tests'

- script: |
${{ parameters.testScript }}
ls -a
displayName: ${{ parameters.testScriptDisplayName }}
workingDirectory: '$(Build.Repository.LocalPath)/API/API-Tests'
failOnStderr: true
continueOnError: false
env:
CI: true

- task: PublishTestResults@2
displayName: 'Publish test results'
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: '**/e2e-junit-results.xml'
# don't need to use searchFolder
#searchFolder: 'ts/playwright'

最佳答案

添加failTaskOnFailedTests PublishTestResults 任务的参数,它会将管道标记为失败 - 但仍为您提供测试报告。

- task: PublishTestResults@2
displayName: 'Publish test results'
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: '**/e2e-junit-results.xml'
failTaskOnFailedTests: true

关于azure - 自动化测试在 Azure 中失败,但该步骤的结果是通过,这是为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76102120/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com