【Eolinker使用实例】同一个脚本如何针对多个数据集做不同响应断言?
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.
【Eolinker使用实例】同一个脚本如何针对多个数据集做不同响应断言?
本周带来了关于响应断言的问题,具体如下:
假设有一个登录的接口,在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
-
58
README.md eoLinker API接口管理系统开源版
-
88
README.md GoKu API Gateway CE(悟空API网关 开源版) 简介 GoKu API Gateway CE,中文名:悟空API网关(开源版),是国内首个开源go语言API网关,帮助企业进行API服务治理、API性能安全维...
-
63
研究动机 近年来关于图像翻译的研究越来越多,其中比较经典的有监督模型包括 Pix2Pix,BicycleGAN等,无监督模型包括CycleGAN, MUNI...
-
8
7 个非常实用的 Shell 拿来就用脚本实例! 2 作者 | 养乐多 责编 | 欧阳姝黎前天,在群里看到有一位读者分享了几道 Shell 脚本实例题目,索性看到了,不如来写写巩固下基础知识,如下:...
-
3
Jager · 6月19日 · 2014年shell练习脚本 199次已读此文将整理一些简单实用、有趣易学的
-
5
阅读时间大约2分钟(590字) ...
-
5
Eolinker获红杉中国种子基金数千万元融资 累计服务数十万开发者
-
2
ASP.NET Core 6框架揭秘实例演示[15]:针对控制台的日志输出 针对...
-
6
可以将字典(Dictionary),理解为存储了关于键-值的成对的二元数组。以下将演示在脚本中利用字典数据结构的实例。
-
6
Eoapi 一个可拓展的 API 工...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK