【问题标题】:How can i raising error while python coverage test on azure devops pipeline?如何在 azure devops 管道上进行 python 覆盖测试时引发错误?
【发布时间】:2020-06-25 02:07:09
【问题描述】:

我的测试代码有些失败。

但管道忽略错误并运行成功。

如何引发错误?

azure-pipelines.yml

...
- script: |
    pipenv run coverage run --rcfile=coverage_config --source='.' manage.py test --keepdb
    pipenv run coverage xml
  displayName: 'Run tests'
  env:
    AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)
    AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
    FLANB_DEBUG: 'True'

- task: PublishCodeCoverageResults@1
  inputs:
    codeCoverageTool: Cobertura
    summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
    reportDirectory: '$(System.DefaultWorkingDirectory)/**/htmlcov'

...

【问题讨论】:

  • 你能分享你的管道配置吗?
  • 尝试添加failOnStderr: true
  • @ShaykiAbramczyk 让我试试。
  • @ShaykiAbramczyk failonstderr 让我总是失败。

标签: python python-3.x azure-devops pipeline coverage.py


【解决方案1】:

如何在 azure devops 管道上进行 python 覆盖测试时引发错误?

当我们使用命令行/powershell/bash 运行测试时,这似乎是一个已知问题。

Publishing test results with failed tests does not fail the build

现在,发布测试结果任务有一个 failTaskOnFailedTests 参数:

- task: PublishTestResults@2
  inputs:
    testRunner: VSTest
    testResultsFiles: '**/*.trx'
    failTaskOnFailedTests: true

您可以尝试使用任务Publish Test Results 和参数failTaskOnFailedTests: true 而不是PublishCodeCoverageResults 来解决此问题。

更多详情请查看this document

要使用 YAML 发布 Python 的测试结果,请参阅Python 这些主题的生态系统部分,其中还包括示例 其他语言。

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-27
    • 2021-02-11
    • 2020-01-08
    • 1970-01-01
    • 2020-12-24
    • 2021-03-08
    • 2017-11-16
    相关资源
    最近更新 更多