前提 需要安装pytest和pytest-html
安装pytest: 在控制台输入 命令 pip install pytest 进行下载安装
安装pytest-html:在控制台输入 命令 pip install pytest-html 进行下载安装
命名规则
Pytest单元测试中的类名和方法名必须是以test开头,执行中只能找到test开头的类和方法,比unittest更加严谨
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210221083806991.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MjcxMzE1MA==,size_16,color_FFFFFF,t_70)
Pytest的运行方式
. 点号,表示用例通过
F 表示失败 Failure
E 表示用例中存在异常 Error
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210221083821331.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl81MjcxMzE1MA==,size_16,color_FFFFFF,t_70)
Pytest生成自带的html测试报告