【Pytest篇】pytest配置文件之pytest.ini

背景      

       pytest.ini配置文件可以改变pytest一些默认的运行方式,通过设置该配置文件,可以按照用户行为习惯进行改进执行过程,如:用例收集规则,标签,命令行参数等等。

pytest.ini文件的创建

        pytest.ini文件一定要放在项目文件根目录下,并且名称一定要是pytest.ini,否则无法正常识别和使用。

[pytest]
# 01.可添加多个命令行参数,用空格分隔
addopts = -s -v

# 02.搜索文件夹,执行指定文件夹里面的用例
testpaths = ./data

# 03.配置搜索测试文件名称,默认是test开头的文件,改成以auto开头,以.py结尾的所有文件
python_files = auto*.py

# 04.配置测试搜索的类名,默认是Test开头的类,改成以Auto开头的类
python_classes = Auto_*

# 05.配置测试搜索的测试函数名,默认是以test开头的方法/函数,改成以auto开头
python_functions = auto_*

# 06.通过标记来执行,标记表达式
markers = 
    slow:
    smoke:
    serial

Supongo que te gusta

Origin blog.csdn.net/weixin_46361114/article/details/120618181
Recomendado
Clasificación