Loading

httpruner3 运行

hrun只是包装了pytest框架,可以直接使用pytest命令运行,把hrun改成pytest即可

注意点:pytest命令只针对.py文件使用,yaml/json文件的得用hrun

如果用hrun会出现

 testcase/testsuite file should be YAML/JSON format

pytest的ini配置文件
pytest.ini文件是pytest的主配置文件,可以改变pytest的默认行为。
1.pytest.ini的放置位置:一般放在项目工程的根目录(即当前项目的顶级文件夹下)
2.pytest.ini的作用:指定pytest的运行方式(在cmd输入pytest后,会读取pytest.ini中的配置信息,按指定的方式去运行)
3.cmd下使用 pytest -h 命令查看pytest.ini的设置选项(以下截图只是部分选项)
常用设置选项如下:
[pytest]
addopts = -s … #可添加多个命令行参数,用空格分隔
testpaths = …/pytestproject #测试用例文件夹,可自己配置,…/pytestproject为上一层的pytestproject文件夹。
python_files = test.py #配置测试搜索的模块文件名称
python_classes = Test
#配置测试搜索的测试类名
python_funtions = test #配置测试搜索的测试函数名

示例如下:

[pytest]
addopts = -s --html=./reports/report.html
testpaths = ./testcases
python_files = test.py
python_classes = Test

python_funtions = test*
注意:
1.运行的时候自动读取配置文件,运行pytestproject下的所有test开头的模块文件。

posted @ 2021-11-28 09:54  封灵寒武  阅读(98)  评论(0编辑  收藏  举报