pytest之配置文件设置

[pytest]:配置文件头信息,不可丢

addopts :命令行参数

addopts := -s -v --html=../report/report.html

python_paths :定义测试用例文件夹名称,只有名称testcase文件夹下面的测试文件才会被pytest执行

python_paths = testcase

python_files:定义测试用例所在的文件,只有文件名称是以test开始的文件才会被pytest执行

python_files=test_*.py

python_classes:定义测试用例文件中类的名称,只有以Test开始的类会被执行

python_classes=Test*

python_functions = test:定义函数或方法的名称,只有以test开始的函数或方法才会被pytest执行

python_functions = test

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
pytest是一个Python的单元测试框架,而allure是一个生成测试报告的工具。在pytest使用allure可以生成漂亮的测试报告,可以方便地查看测试结果和测试覆盖率等信息。 要使用allure,需要安装allure-pytest插件,并在pytest配置文件添加allure的配置。以下是一个示例配置文件: ``` # content of pytest.ini [pytest] addopts = --alluredir=/path/to/allure/reports --clean-alluredir --disable-warnings -v -s -r a --tb=short --strict-markers --color=yes --maxfail=2 markers = smoke: Run the smoke test cases regression: Run the regression test cases # Allure configuration [allure] # The directory to store the allure report # The directory should be created before running the tests # The directory should be empty or not exist before running the tests # The directory should not be the same as the directory specified in the addopts option # The directory should not be a subdirectory of the directory specified in the addopts option # The directory should not be a parent directory of the directory specified in the addopts option # The directory should not contain spaces or special characters # The directory should not be a network drive or a symbolic link # The directory should not be a temporary directory or a system directory # The directory should have write permission allure_report_dir = /path/to/allure/report # The title of the report allure_report_title = My Test Report # The description of the report allure_report_description = This is a test report generated by pytest and allure # The environment information allure_report_environment = {'Browser': 'Chrome', 'OS': 'Windows 10'} ``` 在配置文件,`addopts`选项用于指定pytest的命令行选项,`markers`选项用于定义测试用例的标记。`allure`选项用于配置allure的相关信息,包括报告存储路径、报告标题、报告描述和环境信息等。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值