pytest之main函数的用法
无参构造
运行目录及子目录下的所有用例
pytest.main()
有参构造
1.运行指定模块所有用例
pytest.main([‘testcsv.py’])
2.运行指定模块指定类指定用例,"::" 冒号分隔
pytest.main([‘testcsv.py::TestClass::testMethod’])
3.-q:安静模式, 不输出环境信息
pytest.main([‘testcsv.py’,’-q’])
4.-v: 丰富信息模式, 输出更详细的用例执行信息
pytest.main([‘testcsv.py’,’-v’])
5.-s: 显示程序中的print/logging输出:安静模式, 不输出环境信息
pytest.main([‘testcsv.py’,’-s’])
6.-x:出现一条测试用例失败就退出测试。
pytest.main([‘testcsv.py’,’-x’])
7.–lf:定位失败的用例
pytest.main(["–lf",‘XX.py’])
8.-l:打印失败用例的变量值
pytest.main(["-l",‘XX.py’])
9.使用allure生成 Html 格式的测试报告
split = 'allure ’ + 'generate ’ + './report/result ’ + '-o ’ + './report/html ’ + ‘–clean’
os.system(split)