原文鏈接在這里
斷言總結(jié):
should contain 、 should not contain 與should contain x times
should contain {list_b} 1.0 should not contain{list_b} 1
should contain x times {list_b} 21 2 說(shuō)明:變量{list_b}包含對(duì)象1.0而不包含對(duì)象1周伦,且對(duì)象21在變量${list_b}出現(xiàn)了兩次贷币。
should be empty 與 should not be empty
should be empty {list_c} should not be empty{list_a}
說(shuō)明:變量{list_c}沒(méi)有賦值萨醒,所以為空;相反珊肃,變量{list_a}有賦初始值降盹,故為非空。
should be equal 與 should not be equal
should be equal {list_a[1]}{list_b[1]}
should not be equal {list_a}{list_b}
說(shuō)明:{list_a[1]}=a躲叼,{list_b[1]}=a故兩個(gè)對(duì)象相等;而{list_a}和{list_b}有元素不一致芦缰,這兩個(gè)對(duì)象不相等。
Should Be Equal As Numbers 與 Should not Be Equal As Numbers
Should Be Equal As Numbers {list_b[0]} 1.0000 Should not Be Equal As Numbers{list_b[0]} 1.1
說(shuō)明:${list_b[0]}=1枫慷,忽略精度让蕾,故與1.0000相等;而即使是忽略精度或听,1與1.1還是不相等的探孝;
Should Be Equal As Integers與Should not Be Equal As Integers
Should Be Equal As Integers {list_a[3]}{list_b[3]}
Should not Be Equal As Integers {list_a[4]}{list_b[4]}
說(shuō)明:{list_a[3]}=21,{list_b[3]}=21誉裆,而系統(tǒng)默認(rèn)為字符串格式的“21”,故需要轉(zhuǎn)化為整數(shù)類型顿颅,轉(zhuǎn)化為整數(shù)后兩個(gè)對(duì)象相等;
{list_a[4]}=12足丢,{list_b[4]}=21粱腻,即使轉(zhuǎn)化為整數(shù)后兩個(gè)對(duì)象依舊是不相等;
Should Be Equal As Strings與Should not Be Equal As Strings
Should Be Equal As Strings {list_a[2]}{list_b[2]}
Should not Be Equal As Strings {list_a[0]}{list_b[0]}
說(shuō)明:{list_a[2]}={21}斩跌,{list_b[2]}={21}绍些,而均為數(shù)值型的21,故需要轉(zhuǎn)化為字符串類型,轉(zhuǎn)化為字符串后兩個(gè)對(duì)象相等耀鸦;
Should Be True與Should not Be True
Should Be True {list_a[0]} < 10 Should not Be True{list_a[0]} < 1
說(shuō)明:${list_a[0]}=1(字符串類型)柬批,其ASCII值比字符串10的ASCII值小;
Should start With與Should not start With
Should start With {string} peng Should not start With{string} h
說(shuō)明:${string}=”pengliwen is in hangzhou“是以peng開(kāi)頭氮帐,而非以h開(kāi)頭锻霎;
Should End With與Should not End With
Should End With {string} hangzhou Should not End With{string} pengliwen
說(shuō)明:${string}=”pengliwen is in hangzhou“是以hangzhou結(jié)尾,而非以pengliwen結(jié)尾揪漩;
should match與should not match
should match {name} p?? should not match{string} h?
說(shuō)明:模式匹配和shell中的通配符類似,它區(qū)分大小寫(xiě)吏口,''匹配0~無(wú)窮多個(gè)字符奄容,“?”單個(gè)字符
${name}=plw,由以p開(kāi)頭的三個(gè)字母組成
Should Match Regexp與Should not Match Regexp
Should Match Regexp {name} ^\w{3}
Should not Match Regexp {name} ^\d{3}
說(shuō)明:反斜杠在測(cè)試數(shù)據(jù)是轉(zhuǎn)義字符产徊,因此模式中要使用雙重轉(zhuǎn)義昂勒;'^'和''字符可以用來(lái)表示字符串的開(kāi)頭和結(jié)尾{name}=plw,是有三個(gè)字母--w{3}組成舟铜,而不是由三個(gè)數(shù)字--d{3}組成戈盈。
集合和列表的校驗(yàn)
dictionary should contain item
dictionary should contain key
dictionary should contain sub dictionary
dictionary should contain value
dictionary should not contain key
dictionary should not contain value
convert to dictionary
list should contain sub list
list should contain value
list should not contain value
convert to list
count values in list
get count
get length
數(shù)據(jù)庫(kù)校驗(yàn)
row count is equal to x
row count is greater than x
row count is less than x
循環(huán)遍歷校驗(yàn)
${listtest} set variable 1 a a b
:FOR {li} IN @{listtest} \ log{li}
\ run keyword if ${li}=='a' exit for loop