我在Java中使用了TestNG SoftAssert功能,我们在其中进行多次验证并将每个验证的结果存储在SoftAssert中,并在测试用例结束时断言测试用例和所有验证结果。
我在机器人框架中找不到类似的功能。有谁知道如何实现此功能或使用它(如果存在于 RobotFramework 中(?
您可以使用 Run 关键字并在失败时继续。如果运行的关键字失败,测试将继续运行,并在最后报告失败。
例:
下面是使用此关键字的测试:
*** 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