【问题标题】:Jenkins - run pytest that suspected to fail and get the error data in failure case (but not failing the build)Jenkins - 运行怀疑失败的 pytest 并在失败情况下获取错误数据(但不会失败构建)
【发布时间】:2020-02-16 10:49:10
【问题描述】:

我有几个想要运行但不是强制性的 pytest 测试。这意味着在失败的情况下,Jenkins 构建将成功通过,但我会得到所有的错误数据。

我尝试使用 +e 命令来做这样的事情:

sh("set +e; pytest
--junitxml=$WORKSPACE/test-reports/pytestSourceResults.xml -k TestCode; set -e;")

构建确实没有失败,但我从詹金斯那里得到了不稳定的构建结果。 我怎样才能做类似的事情,但在失败的情况下获得成功?

【问题讨论】:

  • pytest || true?
  • 谢谢,我正在寻找内置(“真实”)解决方案,而不是解决方法
  • 如果您知道这些测试产生的错误(或警告)类型,您可以使用Log Parser plugin 将它们过滤掉(例如,不要将它们视为 Jenkins 的错误/警告)。该插件允许正则表达式定义错误或警告的组成。
  • 您不想使用 xfail 将这些测试标记为“预期失败”吗? (如 doc.pytest.org/en/latest/skipping.html 中所述)

标签: jenkins pytest


【解决方案1】:

我在使用 pytest 和 AWS codebuild 时遇到了同样的问题。

不确定它是否适合您,但我更改为 unittest 库并且它可以工作。

【讨论】:

    猜你喜欢
    • 2019-10-17
    • 2021-07-18
    • 2012-10-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-07
    相关资源
    最近更新 更多