我在Java中使用了TestNG SoftAssert功能,我们在其中进行了多次验证,并将每个验证的结果存储在SoftAssert中,并在测试用例结束时对所有验证结果进行断言测试用例。
我在Robot Framework中找不到类似的功能。没有人知道如何实现此功能或如果它存在于RobotFramework中呢?
答案 0 :(得分:1)
您可以使用Run keyword and continue on failure。如果您运行的关键字失败,则测试将继续运行并在最后报告失败。
示例:
以下是使用此关键字的测试:
*** Test cases ***
Example
run keyword and continue on failure log this passes
run keyword and continue on failure fail this is a failure
run keyword and continue on failure log this also passes
run keyword and continue on failure fail this is also a failure
运行时,您会在控制台上看到它:
==============================================================================
Example
==============================================================================
Example | FAIL |
Several failures occurred:
1) this is a failure
2) this is also a failure
------------------------------------------------------------------------------
Junk | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
您也可以使用该关键字作为测试模板的值,尽管我认为我不建议您将其作为标准做法:
*** Test cases ***
Example
[template] run keyword and continue on failure
log this passes
fail this is a failure
log this also passes
fail this is also a failure