pytest.ini文件是pytest框架独有的配置文件,主要作用就是在运行pytest.main时可指定运行顺序,也
就相当于在Terminal输入pytest+参数+路径效果一致,下面介绍几种简单的写法
1.addopts 指定运行的参数或者生成测试报告
[pytest]
addopts= -s -v
-s 详细输出
-v 输出具体运行的case
-q 简要输出
-m 指定标签(pytest.mark.标签)
-k 指定case
..........
2.markers 定义标签
markers=
ppe: l am ppe
boe
标签名称可任意定义,冒号后面的为该标签说明,可写可不写。若在markers中没有定义的话,运行时会报warning
3.minversion 指定pytest的最低版本(不知道有没有maxversion,这里没试过哈哈哈哈哈)
[pytest] addopts= -s -v markers= ppe: l am ppe boe minversion=7.0.2
4.testpaths 指定运行case的路径
testpaths=./testcase
5.python_files 指定运行哪个.py文件下的,*为通配符
python_files = test_*.py ;|| python_files = test_one.py
6.python_classes 指定运行哪个class,也可跟具体类名
python_classes=Teste*
7.python_functions 指定运行哪条case,也可指定具体case名
python_functions=test_*
8.最后在run.py中写上main运行即可
if __name__ == '__main__': pytest.main()
注意:pytest.ini只对当前类目下的所有case生效