本周帶來了關于回應斷言的問題,具體如下:
假設有一個登錄的介面,在post請求中傳遞兩個引數,分別是username、password、code
第一種場景:username不存在;回應錯誤碼為2000
第二種場景:password錯誤;回應錯誤碼為2001
第三種場景:code錯誤;回應錯誤碼為2002
那么如何通過Eolinker在一個腳本內進行邏輯判斷并做不同的回應斷言呢
用eo.error()代碼
操作流程如下:


在前置腳本中的代碼大致如下,可參考其邏輯:
eo.info(eo.http.bodyParseParam);
if(eo.http.bodyParseParam.username==''){
eo.error("回應錯誤碼為2000")
}
if(eo.http.bodyParseParam.password!=2){
eo.error("回應錯誤碼為2001")
}
if(eo.http.bodyParseParam.code!=3){
eo.error("回應錯誤碼為2002")
}

最后回傳的結果如下:



這周的問題整理大概就這些啦,歡迎大家評論溝通~
使用地址:www.eolinker.com
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/245581.html
標籤:其他
