開源測試報告工具Allure安裝
- 2020 年 3 月 28 日
- 筆記
Allure Test Report 是一款靈活的輕量級多語言測試報告工具。
環境搭建過程
安裝JDK(過程百度)
下載Allure
解壓zip包,進入allure/bin下,該文件下兩個文件allure.bat(windows)和 allure(linux),執行pytest命令用。
使用穩定版,最新版默認沒有bin目錄,為什麼我也不知道~
添加環境變數
將bin目錄加到環境變數。運行allure --version查看是否可用。
安裝第三方庫
pip install allure-pytest。 allure-pytest 暫時只安裝這一個就行,pytest 會被當做依賴安裝好。
執行腳本並生產報告數據
任意創建一個項目,在項目下命令行執行 pytest --alluredir report。
執行pytest 生產allure測試結果數據,存放到report下。
此時在項目下會多一個report 文件夾。
生產測試報告
項目根目錄下執行 allure generate --clean report -o html。執行成功返回:Report successfully generated to html
執行allure生成報告,數據目錄是 report ,報告生成 在html 目錄
打開報告
項目根目錄下執行allure open html。瀏覽器會默認打開報告。
Starting web server... 2020-03-18 23:35:41.157:INFO::main: Logging initialized @209ms to org.eclipse.jetty.util.log.StdErrLog Server started at <http://10.0.63.105:53297/>. Press <Ctrl+C> to exit
allure 命令
Usage: allure [options] [command] [command options] Options: --help Print commandline help. -q, --quiet Switch on the quiet mode. Default: false -v, --verbose Switch on the verbose mode. Default: false --version Print commandline version. Default: false Commands: generate 生成報告 Usage: generate [options] The directories with allure results Options: -c, --clean Clean Allure report directory before generating a new one. Default: false --config Allure commandline config path. If specified overrides values from --profile and --configDirectory. --configDirectory Allure commandline configurations directory. By default uses ALLURE_HOME directory. --profile Allure commandline configuration profile. -o, --report-dir, --output The directory to generate Allure report into. Default: allure-report serve Serve the report Usage: serve [options] The directories with allure results Options: --config Allure commandline config path. If specified overrides values from --profile and --configDirectory. --configDirectory Allure commandline configurations directory. By default uses ALLURE_HOME directory. -h, --host This host will be used to start web server for the report. -p, --port This port will be used to start web server for the report. Default: 0 --profile Allure commandline configuration profile. open Open generated report Usage: open [options] The report directory Options: -h, --host This host will be used to start web server for the report. -p, --port This port will be used to start web server for the report. Default: 0 plugin Generate the report Usage: plugin [options] Options: --config Allure commandline config path. If specified overrides values from --profile and --configDirectory. --configDirectory Allure commandline configurations directory. By default uses ALLURE_HOME directory. --profile Allure commandline configuration pr
安裝過程很簡單。下載解壓,添加環境變數。linux和window沒什麼區別。
之後分享報告使用過程中的心得和技巧~
