(十二)使用pytest管理用例:fixture和conftest使用
pytest下载: pip install pytest 查看pytest版本 pip list 回顾pytest基本用法: pytest 标记:@pytest.mark.名称,可对类或者方法进行标记 指定运行:pytest -m 名称 运行所有用例pytest(以test_开头) 需要import pytest pytest兼容unittest 以pytest方式运行,需要改该工程设置默认的运行器:file->Setting->Tools->Python Integrated Tools->项目名称->Default test runner->选择py.test conftest案例与用法: 案例:在pytest写法中如果test_1.py文件和test_*.py文件中都需要用到登录 用法: 1.在cases目录下新建一个conftest文件,前提该目录下有init.py文件 2.conftest.py配置脚本名称是固定的,不能改名称 3.不需要import导入 conftest.py,pytest用例会自动查找 4.通常与fixture一起使用 5.用例文件名以test开头 类名以test开头 方法名以test开头 conftest.py文件代码+讲解样式: import pytest from taobaoPO.pages.indexPage import