[pytest] ; addopts = -v -s -q --report=_report.html --tester=Phoenixy --title=测试报告 --desc=报告描述信息 --template=2 ; addopts = -v -s -q --html=./reports/result.html --self-contained-html generate_report_on_test = True environment_table_redact_list = ^foo$ .*redact.* bar render_collapsed = failed,error,skipped testpaths = test_case/ui python_files = test_*.py *_test .py test*.py python_classes = Test* Test_* test* test_* python_functions = test_* test* log_file_level = INFO log_file_format = %(asctime)s | %(levelname)s | %(filename)s - %(funcName)s[line:%(lineno)d]: %(message)s log_file_date_format = %Y-%m-%d %H:%M:%S log_cli = True log_cli_level = INFO ; log_cli_format = %(asctime)s | %(levelname)s | %(filename)s - %(funcName)s[line:%(lineno)d]: %(message)s ; log_cli_date_format=%Y-%m-%d %H:%M:%S # --html: 生成html的测试报告,后面 需要跟上所创建的文件位置及文件名称(前提安装插件:pytest-html) ; pytest -vs --html ./reports/result.html ; # -n: 多线程运行(前提安装插件:pytest-xdist) ; pytest -vs -n=2 ; # --reruns num: 失败重跑(前提安装插件:pytest-rerunfailres) ; pytest -vs --reruns=2 ; # -x: 出现一个用例失败则停止测试 ; pytest -vs -x ; # --maxfail: 出现几个失败才终止 ; pytest -vs --maxfail=2 ; # -k: 运行测试用例名称中包含某个字符串的测试用例,我们可以采用or表示或者,采用and表示都 ; pytest -vs -k "qiuluo" ; pytest -vs -k "qiuluo or weiliang" ; pytest -vs -k "qiuluo and weiliang" ; # -m:冒烟用例执行,后面需要跟一个冒烟名称,执行user_manage这个分组 ; pytest -vs -m user_manage ; 下面是解决中文乱码问题:是为了在测试用例收集完成后对测试项的 name 和 nodeid 进行处理,以确保它们在控制台上的显示是正确的。 disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True filterwarnings = error ignore::UserWarning ignore:function ham\(\) is deprecated:DeprecationWarning