pytest的常用日志格式与模块

1,pytest-html

    安装pytest-html插件:pip install pytest-html

    pytest --html=⽤户路径/report.html 要执行的文件

   会自动在当前目录下生成html文件和asserts目录

2, allure

  使用allure-pytest插件生成html格式的测试报告文件

  pytest --alluredir=report(文件夹)  xxx.py

  执行结果生成report文件夹,里面是json格式的测试结果

   pytest --alluredir=report --clean-alluredir xxx.py (重复执行,会叠加测试结果,需要先清空目录,再生成测试结果)

  将json测试结果转换成html格式的报告需安装allure,安装完成后,添加环境变量

  allure generate ./report/temp_jsonreport -o ./report/html --clean

3,生成Junitxml文件,可供后续jenkins持续集成使用

   pytest test_login_dlz.py --junit-xml=../report/log01.xml

4, 除了上面的命令执行外,还可以在程序中直接执行

  生成json格式的测试报告:

  pytest.main(["testCase_demo1.py","-sv","--alluredir","../report/temp_jsonreport"])

  将json测试报告,转换成allure html文件:
  os.system("allure generate ./report/temp_jsonreport -o ./report/html --clean")
 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值