[pytest]
#生成allure报告
addopts= -vs --alluredir=report --clean-alluredir
#指定路径
testpaths= ./testcase
#指定文件
python_files= test_*.py
#指定class
python_classes=Test*
#指定方法
python_functions=test_*
#指明要执行的case
markers=
login
order
smoke
addopts详解:
- -s 详细输出
- -v 输出具体运行的case
--alluredir= report 生成临时报告
--clean-alluredir 清空临时报告
#标记marker
@pytest.mark.login
#执行顺序
@pytest.mark.run(order=1)
def test_login(self,browser_fixture):
conftest.py:管理fixture,一个文件夹下只能有一个conftest.py
@pytest.fixture(scope='class',params=[url])
def browser_fixture(request):
driver = webdriver.Chrome()
driver.get(request.param)
print('打开浏览器'+request.param)
yield driver
driver.quit()
print('关闭浏