1. 程式人生 > >常用斷言關鍵字(rf中)

常用斷言關鍵字(rf中)

串匹配 多少 bsp numbers ria times equal 描述 num

斷言關鍵字

描述

Should Be Empty

判斷是否為空,如果不為空,執行失敗,示例:

${value}

Set Variable

Hello

Should Be Empty

${value}

結果不為空

Should Start With

判斷某個字符串是否以預期執行的字符串開始,如果以指定的字符串開頭,則執行成功,否則執行失敗,示例

${value}

Set Variable

Hello

Should Start With

${value}

qq

字符串${value}不以qq開頭

Should Not Start With

與Should Start With剛好相反,如果以指定的字符串開頭,則執行失敗,否則執行成功,示例:

${value}

Set Variable

Hello

Should Not Start With

${value}

qq

字符串${value}是以qq開頭

Should Match

判斷某個字符串是否與預期指定的字符串相匹配,如果可以匹配,則執行成功,否則執行失敗,示例:

${value}

Set Variable

Hello

Should Match

${value}

qq

字符串${value}不可以匹配qq

Should Not Match

與Should Match剛好相反,如果字符串匹配,則執行失敗,否則執行成功,示例:

${value}

Set Variable

Hello

Should Match

${value}

Hello

字符串${value}可以匹配hello

Should Contain X Times

與Should Contain 關鍵字類似,用來判斷指定的字符串包含指定的字符或者字符串多少次,示例:

${value}

Set Variable

hello

Should Contain X Times

${value}

hello

3

${value}中沒有3次包含字符串hello

Should Be Equal As Integers

以整數的形式來進行比較,示例:

${value}

Set Variable

12

Should Be Equal As Integers

${value}

13

12和13不相等

Should Be Equal As Strings

以字符串的形式來進行比較,示例:

${value}

Set Variable

q

Should Be Equal As Integers

${value}

13

q和13不相等

Should Be Equal As Numbers

以number的形式來進行比較,示例:

${value}

Set Variable

1.0

Should Be Equal As Integers

${value}

1

1.0等於1

Should Not Be Equal

與should be equal 用法相反,當帶比較的兩個值相等時,執行失敗,否則執行成功,示例:

${value}

Set Variable

1.0

Should Not Be Equal

${value}

1.0

1.0等於1.0

Should Not Be Empty

與should be empty 用法相反,如果為空,執行失敗,示例:

${value}

Set Variable

Hello

Should Not Be Empty

${value}

字符串${value}為空

常用斷言關鍵字(rf中)