2

【Eolinker使用实例】同一个脚本如何针对多个数据集做不同响应断言?

 3 years ago
source link: https://segmentfault.com/a/1190000038854829
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

【Eolinker使用实例】同一个脚本如何针对多个数据集做不同响应断言?

发布于 今天 18:15

本周带来了关于响应断言的问题,具体如下:
假设有一个登录的接口,在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


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK