(直接复制就能用,适配pytest.ini配置)一、最常用基础命令bash运行# 运行所有用例(自动加载 pytest.ini 全部配置) pytest # 只看结果,不看详细日志 pytest -q # 只运行上次失败的用例 pytest --lf # 先跑上次失败的,再跑所有用例 pytest --ff二、按目录 / 文件 / 函数运行bash运行# 运行某个目录下所有用例 pytest tests/api/ # 运行单个测试文件 pytest tests/api/test_login.py # 运行文件里的某个类 pytest tests/api/test_login.py::TestLogin # 运行某个具体测试方法 pytest tests/api/test_login.py::TestLogin::test_login_success三、按标记(@pytest.mark)运行bash运行# 只跑冒烟用例 pytest -m smoke # 跑回归用例 pytest -m regression # 跑接口用例 pytest -m interface # 逻辑与:既是接口又是冒烟 pytest -m "interface and smoke" # 逻辑或:接口或UI pytest