Linux下pytest+allure環境搭建


一、安裝依賴包

sudo pip3 install pytest allure-python-commons allure-pytest
sudo apt install openjdk-8-jdk npm

二、安裝npm與node

npm與nodejs的版本要相互對應,這里我們使用npm的版本為6.4.1,nodejs版本為10以上

#這里我們使用npm6.4.1的版本,npm的壓縮gz附件已上傳到文件中,然后再解壓
tar -xzvf    v6.4.1.tar.gz
cd cli-6.4.1
sudo make install
#安裝nodejs
sudo apt-get install nodejs
#查看版本
npm --version
node --version

三、安裝allure命令

sudo npm install -g allure-commandline --save-dev

四、如果默認安裝報錯,則需要用淘寶鏡像源進行注冊,再執行上面的安裝命令

sudo npm install -g less
sudo npm install -g cnpm --registry=https:/registry.npm.taobao.org
sudo npm config set registry https:/registry.npm.taobao.org

五、生成報告

1、生成allure報告

pytest --alluredir ./result/
allure generate ./result/ -o ./report/ --clean
cp  -r ./report/history  ./result/
allure open -h 127.0.0.1 -p 8088 ./report/

二、生成html報告

#安裝pytest-html
sudo pip3 install pytest-html
#生成報告
pytest test_xxxx.py --html=./html/report.html

六、中文支持

cd /usr/local/lib/python3.7/dist-packages/_pytest
sudo vim nodes.py
```
修改內容:
```
#self.name = name
self.name = name.encode("utf-8").decode("unicode_escape")

  

 

 

 

 


免責聲明!

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



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