该框架使用的是
pytest+allure+yaml
暂未对数据库进行数据删除,待优化
源码下载地址:https://github.com/jwb-1221/pytest.git
文件具体配置请往下看
common
未配置,可根据需求配置
config
config.config.py是配置路径
get_token
login.yaml 是获取token需要登录请求的yaml数据
token.yaml 是用来存放请求头token值
write.py 发送登录接口并把获取的token值写入token.yaml文件中
lib
log.py 日志的封装类和方法
new_report.py 获取生成的测试报告(目前已经废弃,现使用allure测试报告,如果已经配置到服务器上只需要IP加端口便可以访问)
read_yaml.py 读取yaml文件的封装类和方法
send_mail.py 发送邮件
send_requests.py 二次封装的request类
log
代码执行的日志
report
[allure测试报告参考图片]
运行pytest框架生成的测试报告,可在pytest.ini文件进行配置需要的路径
testcase
test.py 根据模块写的测试用例
package.txt
需要安装的第三方库,可以快捷安装多个库
pip install package.txt
pytest.ini
运行pytest必须存在的文件,根据配置执行对应目录的用例以及测试报告存放的路径
###生成allure测试报告
allure generate report/result -o report/allure_html --clean
此路径需要和pytest.inip配置文件相对应
扩展知识
linux执行
linux搭建python虚拟环境可参考—linux环境下安装python虚拟环境及注意事项
进入python虚拟环境命令
source tutorial-env(python虚拟环境文件夹)/bin/activate
退出虚拟环境
deactivate
pytest框架部分方法介绍
类的setup,执行该类前执行的函数
def setup_class():
类的tearDown,执行该类后执行的函数
def tearDown_class():
类方法的setup,执行方法前执行的函数
def setup_method():
类方法的tearDown,执行方法后执行的函数
def tearDown_method():
模块的setup,执行模块前执行的函数
def setup_module():
模块的tearDown,执行模块前执行的函数
def tearDown():
函数的setup,执行函数前执行的函数
def setup_function():
函数的tearDown,执行函数前执行的函数
def tearDown_function():
函数指的是不属于任何一个class类的def
有类才会有方法