pytest+allure生成接口自動化測試報告


准備環境

1、安裝pytest  

pip install pytest -i http://pypi.douban.com/simple

 

pytest-ordering

pytest.main([

"-m login",

"-s",  # 輸出打印信息

""

])

 

2、安裝pytest插件

官網翻譯:https://www.jianshu.com/p/f3f13f2e6668

插件匯總:http://plugincompat.herokuapp.com/

pip install pytest-allure-adaptor -i http://pypi.douban.com/simple

 

3、安裝allure

  下載地址: https://github.com/allure-framework/allure2

壓縮包:https://dl.bintray.com/qameta/maven/io/qameta/allure/allure-commandline/2.12.1/allure-commandline-2.12.1.zip

解壓后將allure-2.12.1\bin目錄添加到環境變量

 

 驗證

 

 

4、執行測試

查看用例目錄

 

 在APItesting目錄下執行命令

pytest -s -q cases --alluredir reports\xml

-s  允許終端在測試運行時輸出結果

-q  簡化輸出結果

-- alluredir  生成allure指定文件的語法

 

生產這樣的文件

 

 5、使用allure命令生成測試報告

allure generate reports\xml -o reports\report
reports\xml  這個目錄是執行測試生成的數據
-o reports\report 將測試報告輸出保存到這個目錄下

最終在report目錄下生成以下文件和文件夾

 

 最終在pycharm中打開index.html文件,就可以看到測試報告

 

 

 

參考鏈接:

https://www.cnblogs.com/hao2018/p/9915044.html

https://www.cnblogs.com/xiaoxi-3-/p/9492534.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM