1. 程式人生 > >基於Python的Selenium自動化(4)—如何生成測試報告

基於Python的Selenium自動化(4)—如何生成測試報告

在專案中一般都會使用單元測試框架來對我們的測試程式碼進行管理,python中單元測試框架很多,其中有幾個比較好的單元測試框架,例如:unittest,nose,pytest等。上一篇部落格中介紹了pytest框架的基本使用。這篇文章將介紹的是如何使用pytest生成測試報告

1、生成TXT格式的報告
py.test –resultlog=log.txt

2、生成XML格式的報告
py.test –junitxml=path/log.xml

3、生成HTML格式的報告
這個需要安裝pytest的第三方外掛pytest-html:
pip install -U pytest-html
py.test test_report.py –html=C:\Users\liu.chunming\Desktop\log.html