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
  • 运行用例得到测试报告

    

 欢迎一起交流与指正:

猜你喜欢

转载自www.cnblogs.com/jerry-learn8/p/9763968.html