美文网首页
httprunner学习实践(一)--安装和用例分层

httprunner学习实践(一)--安装和用例分层

作者: 陈凌川 | 来源:发表于2019-07-27 16:10 被阅读0次

序言

httprunner的使用和其中的一些概念在官方的文档中已经详细说明,写这个学习记录是为了记录下自己的学习历程,能够在今后快速的深入学习和实践。没有提及的部分,请查看官方文档
版本:2.2.5

参考

HttpRunner V2.x 中文使用文档

安装方式

$ pip install httprunner

版本升级

$ pip install -U HttpRunner

安装校验

在 HttpRunner 安装成功后,系统中会新增如下 5 个命令:

  • httprunner: 核心命令
  • ate: 曾经用过的命令(当时框架名称为 ApiTestEngine),功能与 httprunner 完全相同
  • hrun: httprunner 的缩写,功能与 httprunner 完全相同
  • locusts: 基于 Locust 实现性能测试
  • har2case: 辅助工具,可将标准通用的 HAR 格式(HTTP Archive)转换为YAML/JSON格式的测试用例

httprunner、hrun、ate 三个命令完全等价,功能特性完全相同,个人推荐使用hrun命令。

运行如下命令,若正常显示版本号,则说明 HttpRunner 安装成功。

$ hrun -V
2.0.2

$ har2case -V
0.2.0

新建工程

使用hrun命令生成项目文件目录,httprunner将创建相应的文件夹

E:\>hrun --startproject testDemo
Start to create new project: testDemo
CWD: E:\

created folder: testDemo
created folder: testDemo\api
created folder: testDemo\testcases
created folder: testDemo\testsuites
created folder: testDemo\reports
created file: testDemo\api\demo_api.yml
created file: testDemo\testcases\demo_testcase.yml
created file: testDemo\testsuites\demo_testsuite.yml
created file: testDemo\debugtalk.py
created file: testDemo\.env
created file: testDemo\.gitignore
  • api文件夹:用以保存单个独立的接口,最好是可以单独运行的
  • testcases文件夹:用以保存有一个或多个接口组成的测试用例
  • testsuites文件夹:多个测试用例的集合
  • reports文件夹:运行测试后生成报表的位置
  • debugtalk.py文件:在文件中定义方法
  • .env文件:自定义变量

相关文章

网友评论

      本文标题:httprunner学习实践(一)--安装和用例分层

      本文链接:https://www.haomeiwen.com/subject/lzeicqtx.html