当前位置:网站首页>Interface automation test platform fasterrunner series (III) - operation examples
Interface automation test platform fasterrunner series (III) - operation examples
2022-07-25 18:47:00 【wangmcn】
Interface automation test platform FasterRunner series ( 3、 ... and )
The operation sample
Catalog
- 1、Get request
- 2、Post request
- 3、 Rely on requests
This article simulates the use of interface request links moco Generate .
About moco Deployment and use of , Clickable moco series Refer to chapter .
1、Get request
Interface request address :
http://localhost:8083/getdemo?username=admin&password=123456
As shown in the figure : First use Postman, Access this interface .
GET request ,2 Parameters username、password
The returned data is admin,123456
1、 Sign in FasterRunner, project (DEMO)、API Templates (module 1)、 Domain name management ( Test environment )、 Configuration Management ( Test configuration ) Created .
Domain name management
Configuration Management
2、API Templates , Add interface , The name of the interface TestGet.
Request method selection GET, Fill in the request address /getdemo
(1)Request: choice params, Fill in 2 Parameters username、password And the corresponding value .
(2)Validate: Fill in the interface assertion .
Check content Comparison mode equals Expected results admin,123456
3、 Execute use cases , For example, select this use case in the use case list , Then select the environment and configuration , Click OK to execute .
Execution results , Interface assertion validation passed .
2、Post request
Interface request address :
http://localhost:8083/postdemo
As shown in the figure : First use Postman, Access this interface .
POST request ,2 Form parameters username、password
The returned data is admin,123456
1、 Sign in FasterRunner, project (DEMO)、API Templates (module 1)、 Domain name management ( Test environment )、 Configuration Management ( Test configuration ) Created .
Domain name management
Configuration Management
2、API Templates , Add interface , The name of the interface TestPost.
Request method selection POST, Fill in the request address /postdemo
(1)Request: Select the form , Fill in 2 Form parameters username、password And the corresponding value .
(2)Validate: Fill in the interface assertion .
Check content Comparison mode equals Expected results admin,123456
3、 Execute use cases , For example, select this use case in the use case list , Then select the environment and configuration , Click OK to execute .
Execution results , Interface assertion validation passed .
3、 Rely on requests
There are two interfaces , Interface 1 There is an interface in the data returned after execution 2 Required request parameters , Then execute the interface 2 when , First execute the interface 1 Get the specified data returned .
Interface 1 Request address :
http://localhost:8083/demo?aaa=123&bbb=456&ccc=789
As shown in the figure : First use Postman, Access this interface .
GET request ,3 Parameters aaa、bbb、ccc
return json The data is :
{
"mystatus": " Successful operation ",
"mytoken": "eyJhbGciOiJIUzI1NiJ9"
}Interface 2 Request address :
http://localhost:8083/demo2
As shown in the figure : First use Postman, Access this interface .
POST request , Request header has 2 Parameters Content-Type、mytoken
return json The data is :
{
"mystatus": " Successful operation ",
"mystatusid": "1"
}Sent json strand .
One 、 Sign in FasterRunner, project (DEMO)、API Templates (module 1)、 Domain name management ( Test environment )、 Configuration Management ( Test configuration ) Created .
Domain name management
Configuration Management
Two 、 Configuration Management , Modify the test configuration
Variables: Fill in the variables ( Interface 1 And interface 2 They all have parameters ccc, It can be set as public ).ccc:789
3、 ... and 、 Global variables
The new variable is named id, Variable value is 1, For interfaces 2 reference .
Four 、 Execution interface 1.
1、API Templates , Add interface , The name of the interface Test1.
Request method selection GET, Fill in the request address /demo
(1)Request: choice params, Fill in 3 Parameters aaa、bbb、ccc And the variable value corresponding to the reference aaa、bbb、
(2)Extract: Extract the return value of the interface ( Interface 2 Will call this variable value )token:content.mytoken
(3)Validate: Fill in the interface assertion ($token Call the extracted return value content.mytoken):
Check status_code Comparison mode equals Expected results 200
Check content.mystatus Comparison mode equals The expected result is successful
Check $token Comparison mode equals Expected results eyJhbGciOiJIUzI1NiJ9
(4)Variables: Fill in local variables , Only in the current interface 1 Use cases work .
aaa:123
bbb:456
2、 Execution interface 1 Use cases , For example, select this use case in the use case list , Then select the environment and configuration , Click OK to execute .
Execution results , Interface assertion validation passed .
5、 ... and 、 Execution interface 2.
1、 Driver code , newly added get_sleep() function
# debugtalk.py
import time
# wait for
def get_sleep(n):
time.sleep(n)2、API Templates , Add interface , The name of the interface Test2.
Request method selection POST, Fill in the request address /demo2
(1)Header: Request header ($token Call extraction interface 1 The return value of content.mytoken):
Content-Type:application/json
mytoken:$token
(2)Request: choice json,json The variable value corresponding to the reference in the string id 、ccc
json strand :
{
"id": "$id",
"username": "test",
"password": "123456",
"ccc": "$ccc"
}(3)Validate: Fill in the interface assertion .
Check status_code Comparison mode equals Expected results 200
Check content.mystatus Comparison mode equals The expected result is successful
Check content.mystatusid Comparison mode equals Expected results 1
(4)Hooks: Set up hook Mechanism .
The method call executed before the test is in the driver code script get_sleep() function , The method of calling this function is ${get_sleep(2)}
It means : When the interface 1 After execution , wait for 2 second , Then execute the interface 2.
3、 The test case , New group TestSuite, Then add use cases , Select the configuration 、 Interface 1、 Interface 2, Save as test set Case1.
4、 Execution group TestSuite, The execution mode is asynchronous .
5、 stay “ Historical report ” Next , View the report execution results , The test result is success .
Open test report , perform 2 Interface ( Execute first Test1, After performing Test2).
Interface assertion validation passed , for example Test2.
边栏推荐
- What is hpapaas platform?
- Address book (II)
- 弱网测试工具-QNET
- Disk performance and capacity
- 论文修改回复1
- 2022年IAA行业品类发展洞察系列报告·第二期
- Pixel2Mesh从单个RGB图像生成三维网格ECCV2018
- R language ggplot2 visual line, custom configuration title text related content color and legend color match (match colors of groups)
- "Wdsr-3" Penglai pharmaceutical Bureau solution
- JVM基础和问题分析入门笔记
猜你喜欢

15. Simple salary management system design

You can change this value on the server by setting the 'Max_ allowed_ Packet 'variable error

对迁移学习中域适应的理解和3种技术的介绍

上半年出货量已超去年全年,森思泰克毫米波雷达“夺食”国际巨头

动态内存管理

单臂路由实验演示(Huawei路由器设备配置)

Add a little surprise to life and be a prototype designer of creative life -- sharing with X contestants in the programming challenge

Northeast people know sexiness best

项目:串口接收—ram存储—TFT显示(完整设计)

推特收购舆论战,被马斯克变成了小孩吵架
随机推荐
通讯录(一)
Chapter 5 Basic Scripting: Shell Variables
Regex 正则表达式
上半年出货量已超去年全年,森思泰克毫米波雷达“夺食”国际巨头
浏览器内核有几种,浏览器版本过低怎么升级
What is 3DE experience platform
弱网测试工具-QNET
年轻时代,噢,年轻时代
What is hpapaas platform?
[translation] logstash, fluent, fluent bit, or vector? How to choose the right open source log collector
进程间的通信(管道通信)
Osmosis通过与Axelar和Moonbeam的集成将跨链足迹扩展至波卡
Ping 命令详解[通俗易懂]
接口自动化测试平台FasterRunner系列(二)- 功能模块
Yyds dry inventory interview must brush top101: reverse linked list
浅析IM即时通讯开发出现上网卡顿?网络掉线?
怎样设计产品帮助中心?以下几点不可忽视
淦,为什么 ““ .length !== 3 ??
What is the difference between GB and gib disk space units?
给生活加点惊喜,做创意生活的原型设计师丨编程挑战赛 x 选手分享