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