Jmeter入门使用2 - 接口自动化

需求:管理后台有个商品保存并上架功能,当我们需要建多个商品时,利用接口自动化实现更方便;商品分为两种,一种有规格,一种无规格;实现方式如下:

Step1-添加元素

1、test plan添加参数,存放token值,token可以在多个thread groups中使用。

 2、添加相关元素

  • http request defaults(设置服务器地址);
  • http header manager(设置请求头部信息);
  • counter(产生自增变量):

The counter config lets the user configure a starting point, a maximum, and the increment. The counter will loop from the start to the max, and then start over with the start, continuing on like that until the test is ended

  • 4个requests:

保存有规格商品(添加JSON Extractor,提取商品spu_id,保存到SpuID)

发布有规格商品(使用参数${SpuID})(添加JSON Assertion,判断是否上架成功)

保存无规格商品(添加JSON Extractor,提取商品spu_id,保存到SpuID)

发布无规格商品(使用参数${SpuID})(添加JSON Assertion,判断是否上架成功)

  • view result tree: 查看结果

counter设置一个开始值,在每个循环中增加1

 

 保存商品的request,需用到counter中的变量${cnt}来改变商品名称

Step2-设置循环

Step3-跑接口

 

查看管理后台数据

the end!!!

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值