在 Robot Framework 中进行断言的最佳方式是什么?

What is the best way of doing assertions in Robot Framework?

我在 Java 中使用 Robot Framework。我的问题是: 在 Robot Framework 中进行断言的最佳方式是什么? 我是否应该导入 JUnit(或类似的库)并在我自己的关键字中使用 if 作为断言?

是否有断言关键字库?我的意思是包含这样的关键字的库:

Assert True &{value_to_check}
Assert List Contains &{list_of_elements} &{element_to_find} # using java equals method

谢谢!

对于大多数用例,您不需要外部库(尤其是 java 库),但请检查 BuiltIn and the Collections 库中烘焙的内容。
您必须显式导入后者,而 BuiltIn 始终可用。

名称中包含 "should" 的所有关键字都是断言 - Should Be True, Should Contain (that's for membership - works on lists, dicts, strings - any container), List Should Contain Sub List, and some even do type casting on the arguments - Should Be Equal As Numbers.

这种模式("should" 被断言)在其他(外部)库中被遵循 - 例如在 SeleniumLibrary 中。