当前位置:网站首页>Pytest interface automation test framework | interface automation to yaml data-driven
Pytest interface automation test framework | interface automation to yaml data-driven
2022-07-22 19:37:00 【COCOgsta】
Video source :B standing 《 Risking your life to upload !pytest Interface automation test framework ( From basic theory to project practice and secondary development ) Teaching video 【 software test 】》
Organize the teacher's course content and test notes while studying , And share it with you , Infringement is deleted , Thank you for your support !
test_py.py
import configparser
import pytest
from loadyaml import read_yaml
from test2 import HttpClient
# project Test a module A function Test different scenarios Sign in Normal scene Abnormal scenario Different test data
# yaml Inside
# Login module
# data yaml
class TestCase:
# Global variables Class variables Public variables You can use
token = None
httpclient = None
url = None
# Sign in from yaml Data fetching from file Specially yaml Take out the data of the file
@pytest.mark.parametrize('udata', read_yaml())
def test_login(self, udata):
print(udata)
TestCase.httpclient=HttpClient()
url = udata['url']
data = udata['data']
res = TestCase.httpclient.send_request(method=udata['method'], url=url, param_type=udata['params_type'], data=data)
print(res.json())
TestCase.token = res.json()['token']
if __name__ == '__main__':
pytest.main(['test_py.py', '-sv'])
loadyaml.py
# Specially yaml Read out the data of the file
import yaml
def read_yaml():
with open('data.yaml', 'r', encoding='utf-8') as f:
data = yaml.load(stream=f, Loader=yaml.FullLoader)
return data
-
url: http://39.98.138.157:5000/api/login
method: post
params_type: json
data:
username: admin
password: '123456'
-
url: http://39.98.138.157:5000/api/login
method: post
params_type: json
data:
username: admin2
password: '123456'
So every time , Will be based on yaml The two pieces of data in the file are executed twice .
边栏推荐
- Solution to unsuccessful (invalid) password modification of MySQL
- 7.19 binary tree
- Force deduction solution summary 1217- playing chips
- 软件产业未来发展的几个趋势
- PHP Cookie
- Day3:分支结构
- Methods of wrapping classes and strings
- 蓝队资源大合集
- Grafana panel - modify visual text and background colors
- Force deduction solution summary 1051 height checker
猜你喜欢
PHP implementation deletes a value in a one-dimensional array
arguments
有向图的连通性
Flutter 第一個程序Hello World!
博士申请 | 香港大学倪卓娴教授招收物联网与机器学习方向全奖博士生
Atmospheric environment monitoring scheme for 4G industrial router
Grafana panel - modify visual text and background colors
30出头成为复旦博导,陈思明:敲代码和写诗,我两样都要
Connectivity of digraph
Rongyun handles political affairs: "small grid" can also achieve "big governance"
随机推荐
Several trends in the future development of software industry
pytest接口自动化测试框架 | 为什么要做pytest插件的二次开发
7.19 binary tree
JS advanced - basic data type and reference data type
PHP implementation deletes a value in a one-dimensional array
Research on the principle of Tencent persistence framework mmkv
PHP Cookie
2022 centos8 Yum image installation & Alibaba cloud MySQL 5.7 tutorial and problem solving
grafana面板-覆盖字段值
问一下,我用flinkCDC读取MySQL的binlog为什么datetime类型字段会早8个小时?
DOM add
Force deduction solution summary 513- find the value of the lower left corner of the tree
Leetcode daily question 2022/2/21-2022/2/27
“35岁,我退休了”:关于中年危机,这是最靠谱的回答
Renjie, chief scientist of rongyun: experience produces talents, and career "experience > experience"
Why is it necessary to rewrite the hashcode method when rewriting the requests method
How many key precautions are there in the process of project implementation?
Leetcode daily question 2022/2/14-2022/2/20
什么是“实时”
河北、浙江的气候变化了?