pytest命令行运行时,可以直接在控制台中查看到输出的结果,但这样的结果并不直观,也不易于保存用于后续分析和分享。如pytest -s -q test_xx.py
的输出结果。
pytest --junitxml=path
pytest --resultlog=path
(不常用,预计在4.0移除)pytest --pastebin=all
,只输出失败的,可以将all换为failedpytest -q --tb=no --junitxml='E:\python_interface_test\results\makejunitstyle.xml'
--tb=no
是不输出traceback信息junit.png
xmlreport.png
pytest -q --tb=no --resultlog='E:\python_interface_test\results\resultlog2.txt'
resultlog.png
logreport.png
pytest --pastebin=all
,如果只想看失败的信息把all换成failed
url.png
urlreport.png
pytest插件的安装和卸载方式为:
pip install pytest-NAME
pip uninstall pytest-NAME
so,安装pytest-html:
python -m pip install pytest-html
pytest-html顾名思义,生成的报告格式为html的。
pytest -q --tb=no --html=E:\python_interface_test\results\makehtml.html
html.png
htmlreport.png
从上面的介绍中看出,JunitXML和pytest-html的可读性和可分析性更好。
作者: 乐大爷 博客:https://www.jianshu.com/u/39cef8a56bf9 声明:本文已获作者授权转载,著作权归作者所有。