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

相关文章:

  • 2021-08-02
  • 2021-12-15
  • 2022-12-23
  • 2021-10-28
  • 2021-12-28
  • 2022-01-26
  • 2021-10-09
猜你喜欢
  • 2021-07-14
  • 2021-12-18
  • 2021-08-02
  • 2022-12-23
  • 2021-12-25
  • 2021-10-21
相关资源
相似解决方案