pip安装
pip install pytest-html
编写脚本
import pytest class TestClass(object): def test_one(self): x = "this" assert 'h' in x test_two(self): x = helloin x
运行程序:
pytest --html=report.html
结果:
C:\Users\haiy\Desktop\code\iot_yjb_api λ pytest --html=report.html ============================ test session starts ============================= platform win32 -- Python 3.7.1rc1,pytest-5.3.5,py-1.8.1,pluggy-0.13.1 rootdir: C:\Users\haiy\Desktop\code\iot_yjb_api plugins: html-2.0.0 collected 2 items test_api.py .. [100%] - generated html file: file://C:\Users\haiy\Desktop\code\iot_yjb_api\report.html - ============================= 2 passed in 0.07s ============================
在当前目录生成一个report.html测试报告文件打开如下
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。