一、配置allure
因为allure是需要java环境的,并且是jdk1.8及以上版本,所以提前在服务器中安装jdk1.8,如图:
下载allure安装,地址:
链接:https://pan.baidu.com/s/1K3hpuwOOmGFX8YKl_s-EZQ
提取码:qs4k
下载后,上传到服务器,我放在了/usr/local这个路径下,解压:unzip allure-2.7.0.zip
如图:
接下来配置allure的环境变量
vi /etc/profile
在后面追加一句:
export PATH=$PATH:/usr/local/allure-2.7.0/bin
:wq保存并退出
加载一下配置文件:source /etc/profile
输入:allure --version
至此,allure配置完毕
二、配置pytest
需要装以下几个依赖包:
pip install requests
pip install schema
pip install jsane
pip install configparser
pip install arrow
pip install pytest-allure-adaptor
pip install pytest==3.10.0
注:因为pytest-allure-adaptor默认安装的版本是1.7.0的,所以pytest的版本不能太高,否则不兼容,这里直接给pytest指定安装版本为3.10.0
安装完后,查看pytest版本:
pytest --version
如果提示没找到pytest,可以在环境变量中配置pytest所在的包
vi /etc/profile
在最后追加一句:
export PATH=$PATH:/usr/local/python3/lib/python3.6/site-packages/
:wq保存后退出
source /etc/profile
此时在pytest --version可以查看版本号
可能使用pip安装依赖包的时候会报网络问题,因为很多centos系统默认是国外的源,使用命令:
pip install 包名 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com