Pytest 生成Report

1. 生成JunitXML 格式的测试报告

JunitXML报告是一种很常用的测试报告,比如可以和Jenkins进行集成,在Jenkins的GUI上显示Pytest的运行结果,非常便利。
运行完case后可以到report路径下去查看相应的xml文件,也可以在PyCharm打开该xml文件查看。
运行

pytest --junitxml=path
#绝对路径:
pytest -v test_one_func.py --junitxml=C:\Users\PycharmProjects\pytest_example\report\test_one_func.xml
#相对路径
pytest -v test_one_func.py --junitxml=report\test_one_func.xml

2. 生成result log格式的测试报告

txt也是最简单的一种测试报告,实例如下。运行完case后可以到report路径下去查看相应的txt文件,也可以在PyCharm打开该txt文件查看。

pytest -v test_one_func.py  --resultlog=report\log.txt

3. 生成Html格式的测试报告

html格式的测试报告在浏览器观看效果很好,还可以把这些测试报告放在Web服务器上。 首先,需要安装pytest-html插件。

pip install pytest-html

pytest -v test_one_func.py --html=report\test_one_func.html

posted on 2017-03-27 13:28  非一  阅读(2789)  评论(0编辑  收藏  举报

导航