pytest中allure自动化测试报告的配置与安装

pytest的allure自动化测试报告的配置与安装

allure的下载安装

  • https://github.com/allure-framework/allure2/releases
  • 打开上面的网址下载最新的allure的压缩包
    在这里插入图片描述
  • 下载好之后解压到英文路径下,我的是
E:\Program Files\allure-2.13.5
  • 之后打开电脑属性的高级系统设置添加环境变量
  • 在系统变量path中添加allure的安装路径并且确定保存,如上文
    在这里插入图片描述
  • 打开cmd输入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      Generate the report
      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 profile.
  • 之后进入pycharm,安装allure-pytest包就可以运行pytest用例
  • 运行语法如下
方法一,在py文件里面写主函数
if __name__ =="__main__":
    # 执行pytest单元测试,生成 Allure 报告需要的数据存在report 目录
    #若没有report目录会自动创建
    pytest.main(['文件名.py','--alluredir',  '/report'])
    # 执行命令 allure generate ,生成测试报告
    #其中report是之前装allure文件的目录
    #clean是清除原先文件夹里的报告
    os.system('allure generate report --clean')
方法二,在pycharm的Dos界面写命令
>pytest --alluredir report
>allure generate report --clean
#原理和方法一类似
  • 执行完之后会发现allure-report文件夹下会有一个index.html文件
  • 用浏览器打开就能发现报告
  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PytestAllure是两个非常流行的测试框架,可以用于搭建接口自动化测试框架。 Pytest是一个功能强大且易于使用的Python测试框架。它支持使用简单的语法编写测试用例,并提供丰富的断言和插件机制。Pytest可以与其他Python库很好地集成,方便编写和管理测试用例。 Allure是一个开源的测试报告框架,它能够生成美观且易于理解的测试报告Allure提供了丰富的报告展示功能,包括测试用例的执行结果、日志、截图等信息。同时,Allure还支持生成历史报告、趋势分析和统计等功能,方便团队进行测试结果的分析和优化。 结合PytestAllure,可以搭建一个完整的接口自动化测试框架。一般来说,你需要按照以下步骤进行配置和编写测试用例: 1. 安装PytestAllure:使用pip命令安装PytestAllurePython库。 2. 编写测试用例:使用Pytest的语法编写接口自动化测试用例,并使用合适的断言进行结果验证。 3. 配置Allure报告:在项目配置Allure报告生成的相关参数,如报告路径、报告名称等。 4. 运行测试用例:使用Pytest命令运行编写的测试用例,并生成Allure测试报告。 5. 查看测试报告:打开生成的Allure测试报告,查看测试结果、日志和截图等信息。 这样,你就可以使用PytestAllure搭建一个简单而功能强大的接口自动化测试框架了。当然,根据实际需求,你还可以结合其他工具和库进行扩展和定制化开发。希望对你有帮助!如果你还有其他问题,请继续提问。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值