Pytest Allure笔记

  1. Pytest 官网
    https://docs.pytest.org/en/latest/contents.html
  2. 命令行执行Pytest
    在项目目录下
pytest 包名/
  1. 测试用例分类
#使用装饰器:
@pytest.mark.testName
def test_div():
	pass
#指定跑的级别
pytest -m 'testName' demo01/
  1. Allure Pytest安装
    Allure 官网: https://docs.qameta.io/allure/#_about
    Pycharm Sitting > Project Interpreter > + > search allure-pytest
  2. Allure Commandline安装
    Linux
    下载allure commandline: allure-commandline-2.13.2.tgz
#解压到任意路径
tar -xzvf allure-commandline-2.13.2.tgz -C ~/Desktop/
#移动到想放置的位置
sudo mv allure-2.13.2/ /opt/allure-2.13.2
#设置环境变量
sudo vi ~/.bashrc
#-----------Allure Commandline Env----
export ALLURE_HOME=/opt/allure-2.13.2/bin
export PATH=$PATH:$ALLURE_HOME
#---------End--------
#生效环境变量
source ~/.bashrc

Windows:
Allure Command Line
配置环境变量: PATH(\安装路径\allure-commandline\bin)
配置环境变量: PATH(\安装路径\allure-commandline\bin)

  1. Allure 测试报告
pytest -s ./src/testsuite/ -o junit_family=xunit2 --junitxml=results/report/test_result.xml --alluredir=results/report/allure_result --clean-alluredir --reruns 3
# -s 控制台显示log 信息
  1. Allure commandline 查看报告
allure serve 报告路径/allue_result/
  1. Allure 生成一个报告便于转发
allure generate results/report/allure_result -o ./results/report/allure_html --clean
  1. Allure 报告浏览
# 命令行进入到allure_html 文件夹下
cd ./results/report/allure_html
# 以下命令可能会存在跨域问题而启动失败. 
# 报错: python.exe: No module named SimpleHTTPServer
# python -m SimpleHTTPServer 8001

# 使用Python 在本地开启一个8000(默认)端口的服务器端
python -m http.server 8001
#然后访问页面
http://localhost:8001
  1. Allure 报告中趋势图(trend) 没有数据
    Trend 没有数据
    解决办法: 将上一次跑的allure_html中的widgets 中的history-trend 数据拷贝放入新的history-trend.json数据中
    编辑新的history-trend.json文件
    修改内容
  2. Allure 报告中的Env 数据

Environment 数据从 environment.properties文件得来.
Allure Env 数据
解决办法: 将environment.properties 文件放入allure-report(这里用的 allue_result) 路径中
Environment.properties 文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值