当前位置:网站首页>Yaml数据驱动演示
Yaml数据驱动演示
2022-06-21 16:00:00 【爆肝拳专业户】
目录:
test_api.yaml:
#用例1--正例
-
name: 获得token鉴权码的接口
request:
url: https://api.weixin.qq.com/cgi-bin/token
method: get
headers:
Content-Type: application/json
params:
grant_type: client_credential
appid: wx6b11b3efd1cdc290
secret: 106a9c6157c4db5f6029918738f9529d
validate:
- eq: {
expires_in: 7200}
#用例2--反例
-
name: 获得token鉴权码的接口
request:
url: https://api.weixin.qq.com/cgi-bin/token
method: get
headers:
Content-Type: application/json
params:
grant_type: client_credential
secret: 106a9c6157c4db5f6029918738f9529d
validate:
- eq: {
expires_in: 7200}
yaml_util.py:
import pytest
import yaml
class YamlUtil:
def __init__(self,yaml_file):
self.yaml_file=yaml_file
def read_yaml(self):
with open(self.yaml_file,encoding='utf-8') as f:
value=yaml.load(f,Loader=yaml.FullLoader)
return value
test_api.py:
import os
import pytest
import requests
from testcase.yaml_util import YamlUtil
class TestApi:
@pytest.mark.parametrize('args',YamlUtil(os.getcwd()+'/testcase/test_api.yaml').read_yaml())
def test_01_baili(self,args):
url=args['request']['url']
params=args['request']['params']
res=requests.get(url,params)
print(res.text)
pytest.ini:
[pytest]
addopts=-vs --alluredir ./temp
testpaths=./testcase
python_files=test_*.py
python_classes=Test*
python_functions=test
all.py:
import os
import pytest
if __name__ == '__main__':
pytest.main()
os.system('allure generate ./temp -o ./report --clean')
测试报告:
边栏推荐
- 未定义的函数或变量【一文讲透】(Matlab)
- AutoK3s v0.5.0 发布 延续简约和友好
- 成长和年龄没有必然联系
- PingCAP 入选 2022 Gartner 云数据库“客户之声”,获评“卓越表现者”最高分
- The database cannot be connected. I don't know what's wrong
- 关于印发《北京市共有产权住房管理暂行办法》的通知
- How to write test cases
- Google Earth Engine(GEE)——用sentinel-2数据获取获取一个月前归一化植被指数NDVI差异(危地马拉为例)
- mysql提升效率
- Esp8266/esp32 get NTP time method through timelib Library
猜你喜欢

Google Play Academy 组队 PK 赛,正式开赛!

How to write test cases

Wechat applet development tutorial - Introduction to text components

微信小程序开发入门教程-文本组件介绍

好用不贵!11款开源自动化安全测试工具简介

Reinforcement learning introductory project spinning up (1) installation

Serious illness insurance covers serious illness. Which product is the best in the market? Please recommend it

为什么要做茶叶商城小程序app开发?

海外new things | 美国人工智能初创「Zoovu」新一轮融资1.69亿美元,为消费者优化线上的“产品发现”体验

依靠可信AI的鲁棒性有效识别深度伪造,帮助银行对抗身份欺诈
随机推荐
网购网站(期末大作业)
Cisco(59)——Hub&Spoke MPLS
The release of autok3s v0.5.0 continues to be simple and friendly
Wechat applet development tutorial - Introduction to text components
Unable to boot device in current state: started - unable to boot device in current state: booted
机器学习中的概念漂移(Aporia)
微信小程序-TabBar用法
4. 构造【LR(1)分析表(包含构建项目规范族)】
Web page automation practice 4. get the name, price and rating information of all hotels and write them into the file
Go语言开发代码自测绝佳go fuzzing用法详解
[live broadcast preview] at 19:00 on June 24, hcsd live broadcast -- employment guide, which will take you through the interview points for the upcoming autumn recruitment and summer internship~~
【1108. IP 地址无效化】
Cloud native hybrid cloud network interconnection
Disruptor本地线程队列_WorkProcessor异常_FatalExceptionHandler---线程间通信工作笔记004
关于印发《北京市共有产权住房管理暂行办法》的通知
微信小程序开发入门介绍-布局组件
首批入围企业公示!年度TOP100智能网联供应商评选
深入理解零拷贝技术
Growth is not necessarily related to age
Advanced performance test series 1. thinking difference, performance concept, performance test