Robotframework 之常用断言关键字简介
1、Should Be Empty
判断是否为空,如果不为空,执行失败,示例:
${value} Set Variable hello
Should Be Empty ${value} 断言结果不为空
2、Should Start With
判断某个字符串是否以预期执行的字符串开始,如果以指定的字符串开头,则执行成功,否则执行失败,示例:
${value} Set Variable hello
Should Start With ${value} kemi 断言字符串${value}不以kemi开头
3、Should Not Start With
与Should Start With刚好相反,如果以指定的字符串开头,则执行失败,否则执行成功,示例:
${value} Set Variable hello
Should Not Start With ${value} kemi 断言字符串${value}是以kemi开头
4、Should Match
判断某个字符串是否与预期指定的字符串相匹配,如果可以匹配,则执行成功,否则执行失败,示例:
${value} Set Variable hello
Should Match ${value} kemi 断言字符串${value}不可以匹配qq
5、Should Not Match
与Should Match刚好相反,如果字符串匹配,则执行失败,否则执行成功,示例:
${value} Set Variable hello
Should Not Match ${value} kemi 断言字符串${value}可以匹配hello
6、Should Be Equal As Integers
以整数的形式来进行比较,示例:
${value} Set Variable 11
Should Be Equal As Integers ${value} 12 断言11和12不相等
7、Should Be Equal As Strings
以字符串的形式来进行比较,示例:
${value} Set Variable hello
Should Be Equal As Strings ${value} kemi 断言hello和kemi不相等
8、Should Be Equal As Numbers
以number的形式来进行比较,示例:
${value} Set Variable 1.0
Should Be Equal As Numbers ${value} 1 断言1.0等于1
9、Should Not Be Equal
与should be equal 用法相反,当带比较的两个值相等时,执行失败,否则执行成功,示例:
${value} Set Variable 1.0
Should Not Be Equal ${value} 1.0 断言1.0等于1.0
10、Should Not Be Empty
与should be empty 用法相反,如果为空,执行失败,示例:
${value} Set Variable hello
Should Not Be Empty ${value} 断言字符串${value}为空