一、前提准备
1、前提:需要安装pytest和pytest-html(生成html测试报告)
pip install pytest 和 pip install pytest-html
安装插件:pip install 插件名
2、命名规范
Pytest单元测试中的类名和方法名必须是以test开头,执行中只能找到test开头的类和方法,比unittest更加严谨
Pytest: setup, setup_class
和
teardown, teardown_class
函数
(
和
unittest
执行效果一样
)
运行于测试方法的始末,即
:
运行一次测试函数会运行一次
setup
和
teardown
运行于测试方法的始末
,
但是不管有多