当前位置:网站首页>MeterSphere教程:接口返回结果为空时如何进行断言
MeterSphere教程:接口返回结果为空时如何进行断言
2022-06-11 00:35:00 【小博测试成长之路】
背景:
最近在使用Metersphere做接口测试的时候,在断言的时候,遇到一些异常的场景是去检查是否查不到数据的这种场景,在断言的时候遇到的问题分享给大家:
先来看如果在python中,返回结果为空是什么样的:

接下来,在平台中调试该接口,进行断言的时候:
1、先尝试断言Response Data是否为null或者"",然后结果如下:

从上面的截图中可以看出,断言最终以失败告终,可能平台针对返回结果为空时,不知道做了什么处理还是有bug,反正这种情况下的断言不方便
2、使用脚本断言
思路:先调用全局函数prev.getResponseDataAsString()拿到返回结果。然后再判断返回结果是不是== "" 。

最终发现这样做是可以断言成功的:

使用的感受:
平台虽然对于不会写代码的人来说,提供了一定的便利,但是,同样有一定的学习成本,尤其是在遇到一定的脚本报错的时候,调试和定位问题不是很方便。
ps:我是在v1.18.xxx的版本上去进行尝试的,不排除后面官方修复了这个问题,或者说是自己的使用方法不对,或者对Response Data的理解有误哈!
参考总结
以上就是本文希望分享的内容,如果大家有什么问题,欢迎在公众号 - 小博测试成长之路留言交流。
写文不易,觉得不错还请一键三连,你们的支持是我持续输出的最大动力。
边栏推荐
- How about compound interest insurance and financial products? Can I buy it?
- Throttling and anti chattering of functions
- MATLAB数组其他常见操作笔记
- CSRF attack
- From "0" to "tens of millions" concurrency, 14 technological innovations of Alibaba distributed architecture
- OCR文字识别经典论文详解
- 数字ic设计自学ing
- 项目_基于网络爬虫的疫情数据可视化分析
- Leetcode 1248 count number of nice subarrays
- Leetcode 1814 count nice pairs in an array (recommended by map)
猜你喜欢
![[VBA Script] extract the information and pending status of all annotations in the word document](/img/dc/0db51d092cde019cef4113796e4882.png)
[VBA Script] extract the information and pending status of all annotations in the word document

threejs:如何获得几何体的boundingBox?

項目_基於網絡爬蟲的疫情數據可視化分析

A tutorial on building a website from scratch with complete steps (7000 words and 102 screenshots for everyone to understand, with source code attached)

Middleware_ Redis_ 05_ Persistence of redis

Application of object storage S3 in distributed file system

Leetcode search questions

detectron2训练自己的数据集和转coco格式

Yunna provincial administrative unit fixed assets management system

Middleware_ Redis_ 06_ Redis transactions
随机推荐
threejs:如何获得几何体的boundingBox?
LeetCode 1609 Even Odd Tree (bfs)
"It looks like robbing tickets but actually robbing money". Don't be fooled by fancy ticket robbing products again and again
What is the C-end and what is the b-end? Let me tell you
Record the packaging of the googlechrome browser plug-in
Docking of express bird system
Configurable custom implementation 1 Implementation interface, 2 Custom configuration 3 Default configuration
Sealem finance builds Web3 decentralized financial platform infrastructure
Leetcode linked list queue stack problem
After a/b machine is connected normally, B machine suddenly restarts. Ask a what is the TCP status at this time? How to eliminate this state in the server program?
detectron2训练自己的数据集和转coco格式
Uninstall mavros
Project_ Visual analysis of epidemic data based on Web Crawler
From "0" to "tens of millions" concurrency, 14 technological innovations of Alibaba distributed architecture
懒汉式单例模式
QGC地面站使用教程
1.6、 PX4初始化校准
多兴趣召回模型实践|得物技术
1.2、ROS+PX4预备基础知识
Garbled code when the command parameter contains% in VisualStudio debugging