pytest 测试报告


测试报告

  • 运行测试用例后,为了保存结果,我们需要生成测试报告,同时可以把运行的测试报告发送相关人员查阅,这时需要安装一个插件(pytest-html)
  • pytest-html插件安装

    pip install -U pytest-html

  • 编写测试用例
    #coding: UTF-8
    import pytest
    class TestClass():
    
        def test_one(self):
            x = "this"
            assert 'h' in x
        def test_two(self):
            x = "hello"
            assert 'a' in x
    if __name__ == '__main__':
        pytest.main("--html=test_report.html")#通过在main中添加命令--html=test_report.html

     

  • 运行用例得到测试报告

    

 欢迎一起交流与指正:

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM