美文网首页
pytest的测试报告pytest-html

pytest的测试报告pytest-html

作者: Chaweys | 来源:发表于2021-06-10 23:02 被阅读0次

    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

    相关文章

      网友评论

          本文标题:pytest的测试报告pytest-html

          本文链接:https://www.haomeiwen.com/subject/tbyasltx.html