pytest的测试报告pytest-html

2021-06-10  本文已影响0人  Chaweys

pytest-html(完美html报告生成)
安装插件
pip install pytest-html -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com


举例:
运行后生成测试报告
import pytest
class Testcase:
    def test_one(self):
        x='hello'
        assert 'e' in x

    def test_two(self):
        x='welcome'
        assert hasattr(x,'check')

if __name__ == '__main__':
    pytest.main(["-v","test_report.py::Testcase","--html=a.html","--self-contained-html"])

注:--self-contained-html 参数如果不加,生成的报告,css是独立的,分享报告的时候样式会丢失,
为了更好的分享发邮件展示报告,可以把css样式合并到html里。
报告1.png
上一篇下一篇

猜你喜欢

热点阅读