2. pytest框架环境搭建

发布时间 2023-07-17 17:51:04作者: WJ-HAHA

 

 

1. 安装pytest

 1 安装pytest:pip pytest 
 2 
 3 三方插件:
 4 
 5 pip install XXX
 6 
 7 pytest-xdist(分布式测试)
 8 pytest-selenium(集成selenium)
 9 pytest-html(完美html测试报告---原生态)
10 pytest-rerunfailures(失败case重复执行)
11 pytest-forked
12 allure-pytest
13 pytest-metadata

 

2. pytets执行测试用例

设计测试用例时必须遵循的规则,否者不识别:
1:.py测试文件必须以test(test_xxx)开头(或者以_test结尾)
2:测试类必须以Test开头,并且不能有init方法-----测试类Test开头
3:测试方法必须以test_开头
4:断言必须使用assert

 

3. 新建package包

项目文件:
lib库文件---(登录接口源代码,其他接口公共的类,封装的库,登录的,订单的)(包)
data文件
---(参数化数据,excel文件,yaml文件,csv文件---测试文件,用例,文档)(可以是普通文件夹)
test_case文件
---(放测试用例的 )(包)   test_func01.py---(测试用例,写的最好见名知意)
report文件
---(存放测试报告的普通文件夹)
config
---(配置文件)

 

 

 

 

 

文章来源:https://blog.csdn.net/csdnchengxi/article/details/124731412