当前位置:网站首页>jmeter接口测试(登录、注册)
jmeter接口测试(登录、注册)
2022-07-27 02:25:00 【测试小鬼】
Jmeter 进行接口测试流程:
Jmeter 的下载地址:http://jmeter.apache.org/download_jmeter.cgi
下面举例说明使用流程,有两种参数传递的方式,我们以登陆、注册分别举例
1、先添加线程组,参数设置如图
线程数:可以理解成登陆账号的数量
循环次数:就是循环执行你设置的线程数
如图表示:10秒内执行10个线程,循环2次,总共执行了20次
循环次数如果选择永远,程序会一直执行,除非手动停止

2、添加http请求:参数设置如下
协议:看服务部署的是http还是https,这里选择http
一般开发需要你去测试接口会给一个地址:http://www.patballoon.com/auth/register或者http://121.43.191.73:3100/auth/register
服务器名称:www.patballoon.com
端口号:3100 如果选择域名的话端口号可以为空
路径:/auth/register
方法:post
同请求一起传递的参数:这里测试的是注册,所以传递的参数有:账号,密码,地址

下图可以添加参数,参数个数要看接口代码,这里需要传递如图:username\password\address
3 、添加聚合报告、查看结果树、用表格查看结果,都是为了分析测试的结果。简单分析一下报告,sample:20个就是我们一开始在线程组设置的参数

4、查看结果树
左图绿色代表通过,右边是一些测试的结果,可是查看每一次的http的请求情况以及相应数据

上面是注册的接口,下面演示登陆的接口测试,登陆我们可能用到的数据比较多,所以我们需要把数据写在一个文档里,用 jmeter来调用,其他俩程都是一样的,不一样的是要用到csv 存数据:
1、我们先把测试的数据存到文档里,如下图1,登陆需要的接口参数看代码,图1中参数为Username、Password、Auth,这里模拟4个用户

2、 添加csv ,如图2参数设置:
filename:这个是上图1我们设置的用户,保存的文档路径
Lgnore first line :这个是图1文档是否去掉第一行,选择是
Variable name:变量名字是自己定义的

3、http请求设置如图3:
添加参数:名称为接口代码定义的参数,值要和图中的形式一样,参数和图2定义的保持 一致

4、聚合报告和注册时一样查看
聚合报告:如果添加在线程组下面是单个线程的报告结果如上图
下面是添加在线程组外面的聚合报告,现实两个线程组饿报告结果

边栏推荐
- 复盘:DFS与BFS的主要区别,在思想上的区别,代码实现上的区别
- 深圳家具展首日,金可儿展位三大看点全解锁!
- Introduction to database - Introduction to database
- 复盘:图像有哪些基本属性?关于图像的知识你知道哪些?图像的参数有哪些
- Feitengtengrui d2000 won the "top ten hard core technologies" award of Digital China
- 次轮Okaleido Tiger即将登录Binance NFT,引发社区热议
- Okaleido tiger is about to log in to binance NFT in the second round, which has aroused heated discussion in the community
- Meta Quest内容生态总监谈App Lab设计初衷
- Detailed tutorial of typera
- Vector to SVG method
猜你喜欢

数字孪生实际应用:智慧城市项目建设解决方案

函数指针与回调函数

Record the problem of PHP program accessing system files incorrectly

Mysql database related operations

Contour detection based on OpenCV (2)

复盘:图像有哪些基本属性?关于图像的知识你知道哪些?图像的参数有哪些

04.在谷歌浏览器中安装模拟浏览器ChromeDriver的详细步骤

On the first day of Shenzhen furniture exhibition, the three highlights of Jin Ke'er booth were unlocked!

复盘:DFS与BFS的主要区别,在思想上的区别,代码实现上的区别

深圳家具展首日,金可儿展位三大看点全解锁!
随机推荐
Is Jiufang intelligent investment a regular company? Talk about Jiufang intelligent investment
The new version of Alibaba Seata finally solves the idempotence, suspension and empty rollback problems of TCC mode
Introduction to database - a brief introduction to MySQL
Contour detection based on OpenCV (2)
数字孪生应用及意义对电力的主要作用,概念价值。
Application, addition and deletion of B-tree
Message queue learning -- Concepts
Typescript TS basic knowledge interface, generics
Design method and test method of APP interface use case
智能体重秤方案主控采用CSU18M91
Daffodils (day 78)
Leetcode- > dichotomy (III)
Food chain (day 79)
深圳家具展首日,金可儿展位三大看点全解锁!
Regression testing: meaning, challenges, best practices and tools
Record the problem of PHP program accessing system files incorrectly
Director of meta quest content ecology talks about the original intention of APP lab design
基于OpenCV的轮廓检测(2)
Contour detection based on OpenCV (1)
Ming min investment Qiu Huiming: behind the long-term excellence and excess, the test is the team's investment and research ability and the integrity of strategy