Robotframework:如何将通过的测试显示为 "PASS",即使套件拆解是 "Fail"

Robotframework: how to show passed test as "PASS" even if suite teardown were "Fail"

我在以下环境使用机器人框架。

我是这样使用robotframwork的。

*** settings ***
Suite Setup       setupkeyword # Provisioning for test
Suite Teardown    teardownkeyword # Delete all resources

*** testcases ***
TestCase1
TestCase2
TestCase3...

在这种情况下, 如果 Teardown 失败,测试用例会在报告中显示为失败,如下所示。

Suite Setup:PASS
Suite Teardown:FAIL
TestCase1:FAIL
TestCase2:FAIL
TestCase3:FAIL

但Teardown不是本次测试的目的, 所以我想要报告显示如下。

Suite Setup:PASS
Suite Teardown:FAIL
TestCase1:PASS
TestCase2:PASS
TestCase3:PASS

我测试如下。

Suite Teardown    Run Keyword And Ignore Error    teardownkeyword # Delete all resources

但在这种情况下,报告显示

Suite Teardown:PASS

但我想知道是否通过了Teardown

这种情况有什么好的方法吗?

我认为最好的方法是重新设计 teardown 关键字以在即将失败时发出警告(但避免失败)。可以用log关键字来完成:

Log    This keyword would fail due a some reason    level=WARN

你可以尝试使用 level=ERROR(也许它不会让整个测试套件失败?)