一级目录
Pytest
需要安装pytest和pytest-html(生成html测试报告)
pip install pytest 和 pip install pytest-html
命名规则
Pytest单元测试中的类名和方法名必须是以test开头,执行中只能找到test开头的类和方法,比unittest更加严谨
1、创建Python项目,安装pytest、allure-pytest
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/ddad21a718f222f27b2c7a0f0bc4f68f.png)
2、然后在项目里面创建一个文件夹,文件夹中创建一个calas.py的文件 .py文件任意,这个文件相当于开发给测试的文件。
class Cala():
def jia(self, a, b):
c = a + b
return c
def jian(self, a, b):
c = a - b
return c
3、开发文件拿到后,我们创建测试文件夹testDemo,创建test1.py
import pytest
import pytest_html
from funcDemo.calas import Cala
class TestClass():
def setup(self):
print('setup.....start')
def setup_class(self):
print('se