![](https://img-blog.csdnimg.cn/20211009105309339.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA6Zi_5Lyf55qESVTkuYvot68=,size_20,color_FFFFFF,t_70,g_se,x_16)
![](https://img-blog.csdnimg.cn/20211009105601200.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA6Zi_5Lyf55qESVTkuYvot68=,size_20,color_FFFFFF,t_70,g_se,x_16)
:命名规则
![](https://img-blog.csdnimg.cn/20211009112655215.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA6Zi_5Lyf55qESVTkuYvot68=,size_18,color_FFFFFF,t_70,g_se,x_16)
显示没有测试用例
我们改了一个名字就可以了
![](https://img-blog.csdnimg.cn/20211009113126911.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA6Zi_5Lyf55qESVTkuYvot68=,size_20,color_FFFFFF,t_70,g_se,x_16)
除了这种还有一种也可以:
如下:指定一下就行
安装pytest-html:
命令:pip install pytest-html
pytest生成自带的html测试报告
(需要先下载,我下载的方法在上边^)
代码如下:
pytest.main(["--html=./report.html","模块.py"])
若只向跑一个
pytest调用语句
语句: pytst.main(['-x','--html=./report.html','t12est000.py'])
-x出现一条测试用例失败就退出测试
-s:显示print内容
使用-x:的方式
使用@pytest.mark.skip()跳过该用例(函数)
文件读取:xml
csv
allure
![](https://img-blog.csdnimg.cn/20211009202643252.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA6Zi_5Lyf55qESVTkuYvot68=,size_17,color_FFFFFF,t_70,g_se,x_16)
配置成功
安装allure:
命令:pip insert allure-pytest
allure常用的几个特性
@allure.feature # 用于描述被测试产品需求
@allure.story # 用于描述feature的用户场景,即测试需求
with allure.step(): # 用于描述测试步骤,将会输出到报告中
allure.attach # 用于向测试报告中输入一些附加的信息,通常是一些测试数据,截图等
案例:
@allure.feature # 用于描述被测试产品需求
@allure.story # 用于描述feature的用户场景,即测试需求
with allure.step(): # 用于描述测试步骤,将会输出到报告中
allure.attach # 用于向测试报告中输入一些附加的信息,通常是一些测试数据,截图等