HttpRunner 是一个开源的 API 测试工具,支持 HTTP(S) / HTTP2 / WebSocket / RPC 等网络协议,涵盖接口测试、性能测试、数字体验监测等测试类型。简单易用,功能强大,具有丰富的插件化机制和高度的可扩展能力。

HttpRunner

Github Actions codecov Go Reference downloads pypi version pyversions TesterHome

HttpRunner 是一个开源的 API 测试工具,支持 HTTP(S)/HTTP2/WebSocket/RPC 等网络协议,涵盖接口测试、性能测试、数字体验监测等测试类型。简单易用,功能强大,具有丰富的插件化机制和高度的可扩展能力。

HttpRunner 用户调研问卷 持续收集中,我们将基于用户反馈动态调整产品特性和需求优先级。

flow chart

版本发布日志 | English

设计理念

相比于其它 API 测试工具,HttpRunner 最大的不同在于设计理念。

  • 约定大于配置:测试用例是标准结构化的,格式统一,方便协作和维护
  • 标准开放:基于开放的标准,支持与 HAR/Postman/Swagger/Curl/JMeter 等工具对接,轻松实现用例生成和转换
  • 一次投入多维复用:一套脚本可同时支持接口自动化测试、性能测试、数字体验监测等多种 API 测试需求
  • 融入最佳工程实践:不仅仅是一款测试工具,在功能中融入最佳工程实践,实现面向网络协议的一站式测试解决方案

核心特性

  • 网络协议:完整支持 HTTP(S)/HTTP2/WebSocket,可扩展支持 TCP/UDP/RPC 等更多协议
  • 多格式可选:测试用例支持 YAML/JSON/go test/pytest 格式,并且支持格式互相转换
  • 双执行引擎:同时支持 golang/python 两个执行引擎,兼具 go 的高性能和 pytest 的丰富生态
  • 录制 & 生成:可使用 HAR/Postman/Swagger/curl 等生成测试用例;基于链式调用的方法提示也可快速编写测试用例
  • 复杂场景:基于 variables/extract/validate/hooks 机制可以方便地创建任意复杂的测试场景
  • 插件化机制:内置丰富的函数库,同时可以基于主流编程语言(go/python/java)编写自定义函数轻松实现更多能力
  • 性能测试:无需额外工作即可实现压力测试;单机可轻松支撑 1w+ VUM,结合分布式负载能力可实现海量发压
  • 网络性能采集:在场景化接口测试的基础上,可额外采集网络链路性能指标(DNS 解析、TCP 连接、SSL 握手、网络传输等)
  • 一键部署:采用二进制命令行工具分发,无需环境依赖,一条命令即可在 macOS/Linux/Windows 快速完成安装部署

用户声音

基于 252 份调研问卷的统计结果,HttpRunner 用户的整体满意度评分 4.3/5,最喜欢的特性包括:

  • 简单易用:测试用例支持 YAML/JSON 标准化格式,可通过录制的方式快速生成用例,上手简单,使用方便
  • 功能强大:支持灵活的自定义函数和 hook 机制,参数变量、数据驱动、结果断言等机制一应俱全,轻松适应各种复杂场景
  • 设计理念:测试用例组织支持分层设计,格式统一,易于实现测试用例的维护和复用

更多内容详见 HttpRunner 首轮用户调研报告(2022.02)

一键部署

HttpRunner 二进制命令行工具已上传至阿里云 OSS,在系统终端中执行如下命令可完成安装部署。

$ bash -c "$(curl -ksSL https://httprunner.com/script/install.sh)"

安装成功后,你将获得一个 hrp 命令行工具,执行 hrp -h 即可查看到参数帮助说明。

$ hrp -h

██╗  ██╗████████╗████████╗██████╗ ██████╗ ██╗   ██╗███╗   ██╗███╗   ██╗███████╗██████╗
██║  ██║╚══██╔══╝╚══██╔══╝██╔══██╗██╔══██╗██║   ██║████╗  ██║████╗  ██║██╔════╝██╔══██╗
███████║   ██║      ██║   ██████╔╝██████╔╝██║   ██║██╔██╗ ██║██╔██╗ ██║█████╗  ██████╔╝
██╔══██║   ██║      ██║   ██╔═══╝ ██╔══██╗██║   ██║██║╚██╗██║██║╚██╗██║██╔══╝  ██╔══██╗
██║  ██║   ██║      ██║   ██║     ██║  ██║╚██████╔╝██║ ╚████║██║ ╚████║███████╗██║  ██║
╚═╝  ╚═╝   ╚═╝      ╚═╝   ╚═╝     ╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═══╝╚═╝  ╚═══╝╚══════╝╚═╝  ╚═╝

HttpRunner is an open source API testing tool that supports HTTP(S)/HTTP2/WebSocket/RPC
network protocols, covering API testing, performance testing and digital experience
monitoring (DEM) test types. Enjoy! ✨ 🚀 ✨

License: Apache-2.0
Website: https://httprunner.com
Github: https://github.com/httprunner/httprunner
Copyright 2017 debugtalk

Usage:
  hrp [command]

Available Commands:
  boom         run load test with boomer
  completion   generate the autocompletion script for the specified shell
  har2case     convert HAR to json/yaml testcase files
  help         Help about any command
  pytest       run API test with pytest
  run          run API test with go engine
  startproject create a scaffold project

Flags:
  -h, --help               help for hrp
      --log-json           set log to json format
  -l, --log-level string   set log level (default "INFO")
  -v, --version            version for hrp

Use "hrp [command] --help" for more information about a command.

赞助商

金牌赞助商

霍格沃兹测试开发学社

霍格沃兹测试开发学社是业界领先的测试开发技术高端教育品牌,隶属于测吧(北京)科技有限公司 。学院课程由一线大厂测试经理与资深测试开发专家参与研发,实战驱动。课程涵盖 web/app 自动化测试、接口测试、性能测试、安全测试、持续集成/持续交付/DevOps,测试左移&右移、精准测试、测试平台开发、测试管理等内容,帮助测试工程师实现测试开发技术转型。通过优秀的学社制度(奖学金、内推返学费、行业竞赛等多种方式)来实现学员、学社及用人企业的三方共赢。

进入测试开发技术能力测评!

开源服务赞助商

Sentry

HttpRunner is in Sentry Sponsored plan.

Subscribe

关注 HttpRunner 的微信公众号,第一时间获得最新资讯。

HttpRunner

如果你期望加入 HttpRunner 核心用户群,请填写用户调研问卷并留下你的联系方式,作者将拉你进群。

Comments
  • 参数化所有用例都取第一个值

    参数化所有用例都取第一个值

    问题描述

    请对遇到的 bug 进行简要描述。

    版本信息

    请提供如下版本信息:

    • 操作系统类型: [e.g. macos]
    • Python 版本 [e.g. 3.6]
    • HttpRunner 版本 [e.g. 3.1.6]
    • 设备 ID: [e.g. 190070690681122]

    项目文件内容(非必须)

    config:
      name: login
      base_url: ${ENV(HOST)}
      variables:
        username: '${ENV(ADMIN_USER)}'
        password: '${ENV(PASSWORD)}'
      export:
        - token
    
    teststeps:
      - name: login
        request:
          method: POST
          url: /login
          json: { 'username': '${username}', 'password': '${password}'}
        extract:
          token: "body.data.token"
        validate:
          - eq: [ "body.code", '300' ]
    
    config:
      name: login
      parameters:
        username: [ "zhangsan", "lisi", "xiaoming" ]
        password: [ "zhangsan123", "lisi123", "xiaoming123" ]
    
    teststeps:
      - name: "login"
        testcase: testcases/admin/login/login.yaml
        variables:
          username: '${username}'
          password: '${password}'
    
    
    
    

    运行命令 && 堆栈信息

    请提供在命令行中运行测试时所在的目录和命令,以及报错时的详细堆栈内容。

    hrun testsuites/admin/login/login.yaml --html=./reports/report.html
    

    日志文件

    logs.zip

  • [bug] request json body is a list

    [bug] request json body is a list

    问题描述

    我们的新增接口只会返回status code,response中不会返回任何。用postman直接调用是返回的200. 但是使用httprunner的话就报错

    版本信息

    请提供如下版本信息:

    • 操作系统类型: [ Windows]
    • Python 版本 [3.6]
    • HttpRunner 版本 [2.1.2]

    报错信息


    Traceback (most recent call last): ValueError: invalid literal for int() with base 16: b''

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): http.client.IncompleteRead: IncompleteRead(0 bytes read)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))

    image

  • 请求中verify参数设置为False无效

    请求中verify参数设置为False无效

    问题描述

    在config配置中设置verify参数为false,实际执行时仍会验证证书。

    版本信息

    请提供如下版本信息:

    • 操作系统类型: [e.g. Windows]
    • Python 版本 [e.g. 3.7]
    • HttpRunner 版本 [e.g. 2.0.0]

    堆栈信息

    Traceback (most recent call last): File "C:\Program Files\Python37\lib\site-packages\httprunner\api.py", line 54, in test test_runner.run_test(test_dict) File "C:\Program Files\Python37\lib\site-packages\httprunner\runner.py", line 347, in run_test self._run_test(test_dict) File "C:\Program Files\Python37\lib\site-packages\httprunner\runner.py", line 234, in _run_test **parsed_test_request File "C:\Program Files\Python37\lib\site-packages\httprunner\client.py", line 205, in request for resp_obj in response_list File "C:\Program Files\Python37\lib\site-packages\httprunner\client.py", line 205, in for resp_obj in response_list File "C:\Program Files\Python37\lib\site-packages\httprunner\client.py", line 102, in get_req_resp_record req_resp_dict["response"]["ok"] = resp_obj.ok File "C:\Program Files\Python37\lib\site-packages\requests\models.py", line 701, in ok self.raise_for_status() File "C:\Program Files\Python37\lib\site-packages\httprunner\client.py", line 20, in raise_for_status raise self.error File "C:\Program Files\Python37\lib\site-packages\httprunner\client.py", line 233, in _send_request_safe_mode return requests.Session.request(self, method, url, **kwargs) File "C:\Program Files\Python37\lib\site-packages\requests\sessions.py", line 512, in request resp = self.send(prep, **send_kwargs) File "C:\Program Files\Python37\lib\site-packages\requests\sessions.py", line 622, in send r = adapter.send(request, **kwargs) File "C:\Program Files\Python37\lib\site-packages\requests\adapters.py", line 511, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='www.homelabs.cn', port=443): Max retries exceeded with url: /api/v1/login (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)')))


    Ran 1 test in 0.445s

    FAILED (errors=1) variable 'role' can not be found in variables mapping, failed to output!

    项目文件结构

    .env │ debugtalk.py │ main.py │ ├─.idea │ │ misc.xml │ │ modules.xml │ │ test.iml │ │ workspace.xml │ │ │ └─inspectionProfiles ├─api │ ├─json │ │ │ │ │ ├─api_v1_login │ │ │ post.json │ │ │ │ │ ├─api_v1_logout │ │ │ get.json │ ├─reports │ 1546595125.html │ 1546595143.html │ ├─testcases │ ├─login │ │ 密码登录.yml │ │ 账号不存在时登录.yml │ │ 验证码登录.yml │ │ │ └─reports │ 报告上传.yml │ ├─testsuites ├─tools │ │ database.py

    项目文件内容(非必须)

    -   config:
            name: 正常登陆接口测试1
            base_url: ${get_base_url()}
            verify: false
            request:
              headers:
                Accept: application/json
                User-Agent: iOS/10.3
            variables:
              -  act: ${random_account()}
              -  pwd: "${md5(123456)}"
              -  role: 1
            "output": [
              role,
            ]
    -   test:
          parameters:
          - identityType: [passwd]
          variables:
          - role: 2
          setup_hooks:
          - ${init_act($act, $pwd, $role)}
          name: 正常登陆接口测试
          api: api/yml/api_v1_login/post.yml
          validate:
          - eq: ["status_code", 200]
          - eq: ["content.respStatus.code", 200]
    

    提示:请注意在去除项目敏感信息(IP、账号密码、密钥等)后再进行上传。

  • 带中文参数请求会转为unicode,并且2.1.2无法通过data关键字解决

    带中文参数请求会转为unicode,并且2.1.2无法通过data关键字解决

    问题描述

    遇到了 https://github.com/HttpRunner/HttpRunner/issues/395#issue-363556841 的问题,尝试使用data关键字解决时报错,提示编码问题

    版本信息

    请提供如下版本信息:

    • 操作系统类型: [Windows]
    • Python 版本 [3.7]
    • HttpRunner 版本 [2.1.2]

    项目文件内容(非必须)

    name: 登录
    base_url: ${ENV(base_url)}
    variables:
        username: 用户名
        password: 密码
    
    request:
        method: POST
        url: /v1/systemUser/login
        headers:
            Content-Type: text/plain
        data: '{"username": "$username","password": "$password"}'
        # json:
        #     username: $username
        #     password: $password
    
    validate:
        - eq:
              - status_code
              - 200
    

    运行命令 && 堆栈信息

    Traceback (most recent call last): UnicodeEncodeError: 'latin-1' codec can't encode characters in position 14-16: Body ('用户名') is not valid Latin-1. Use body.encode('utf-8') if you want to send it encoded in UTF-8.

  • testcases下定义了用例参数,运行提示找不到参数

    testcases下定义了用例参数,运行提示找不到参数

    testcases文件下,存在以下用例smoketest.yml:

    - config:
        name: smoketest
        request: $default_request  
    - test:
        name: 错误账密登录测试
        parameters:
            - userid-password:
                - ["xxx", "xxx"]
        suite: loginSuite($userid, $password)
    

    suite文件下,存在以下:

    - config:
        name: "suittest"
        def: loginSuite($userid, $password)
        request: $default_request
    - test:
        name: 获取token
        api: login($userid, $password)
    

    api文件下,存在以下:

    - api:
        def: login($userid, $password) 
        request:
          url: 'xxx'
          headers: {}
          method: POST
          data:
            simpleAccountService.login: |-
              {
                "areaCode" : "86",
                "password" : "$password",
                "userid" : $userid,
                }
              }
    

    为啥hrun tests/testcases/smoketest.yml时候提示httprunner.exception.VariableNotFound: password not found in recursive upward path!,求指教

  • parameters的csv中包含中文时出现UnicodeDecodeError

    parameters的csv中包含中文时出现UnicodeDecodeError

    使用parameters指定参数列表,当csv中含有中文时,报错如下:

    Traceback (most recent call last):
      File "C:\Python36\Scripts\hrun-script.py", line 11, in <module>
        load_entry_point('HttpRunner==1.4.4', 'console_scripts', 'hrun')()
      File "c:\python36\lib\site-packages\httprunner\cli.py", line 82, in main_hrun
        runner = HttpRunner(failfast=args.failfast, dot_env_path=args.dot_env_path).run(args.testset_paths)
      File "c:\python36\lib\site-packages\httprunner\task.py", line 242, in run
        task_suite = init_task_suite(path_or_testsets, mapping)
      File "c:\python36\lib\site-packages\httprunner\task.py", line 206, in init_task_suite
        return TaskSuite(testsets, mapping, http_client_session)
      File "c:\python36\lib\site-packages\httprunner\task.py", line 187, in __init__
        suite = TestSuite(testset, mapping, http_client_session)
      File "c:\python36\lib\site-packages\httprunner\task.py", line 76, in __init__
        config_dict_parameters
      File "c:\python36\lib\site-packages\httprunner\task.py", line 116, in _get_parametered_variables
        self.testset_file_path
      File "c:\python36\lib\site-packages\httprunner\testcase.py", line 712, in parse_parameters
        parsed_parameter_content = testcase_parser.eval_content_with_bindings(parameter_content)
      File "c:\python36\lib\site-packages\httprunner\testcase.py", line 915, in eval_content_with_bindings
        content = self._eval_content_functions(content)
      File "c:\python36\lib\site-packages\httprunner\testcase.py", line 813, in _eval_content_functions
        eval_value = self.parameterize(*args, **kwargs)
      File "c:\python36\lib\site-packages\httprunner\testcase.py", line 794, in parameterize
        csv_content_list = FileUtils.load_file(parameter_file_path)
      File "c:\python36\lib\site-packages\httprunner\utils.py", line 128, in load_file
        return FileUtils._load_csv_file(file_path)
      File "c:\python36\lib\site-packages\httprunner\utils.py", line 112, in _load_csv_file
        for row in reader:
      File "c:\python36\lib\csv.py", line 111, in __next__
        self.fieldnames
      File "c:\python36\lib\csv.py", line 98, in fieldnames
        self._fieldnames = next(self.reader)
      File "c:\python36\lib\codecs.py", line 321, in decode
        (result, consumed) = self._buffer_decode(data, self.errors, final)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd6 in position 76: invalid continuation byte
    'utf-8' codec can't decode byte 0xd6 in position 76: invalid continuation byte
    
  • 关于sign值生成问题

    关于sign值生成问题

    请教一个关于sign值生成问题

    问问题之前要先解释下我司的sign值生成方式,所有的参数以key1=value1&key2=value2的格式按照首字母顺序排序后加上一个secret进行md5加密后生成的。

    如果按照中文手册中的示例一样在用例中用函数去调用加密函数的时候再去传值,当参数过多的时候会很不方便。

    开始我想是在debugtalk.py中写一个函数然后通过用例名称去读取文件,但是后来发现参数化的参数不行。

    后来我自己YY能不能像截图中这样子弄,但行不通。 image

    想请教下怎么才能很方便的去读取请求中param部分去生成sign值,不用每个用例都去填写一遍键值对~~

    想了好久没有想出来~~~~ 希望我没有问了一个很蠢的问题~~~~(〃'▽'〃)

  • 在大量并发下DNS解析会出问题。

    在大量并发下DNS解析会出问题。

    Traceback (most recent call last): ConnectionError: HTTPConnectionPool(host='ip', port=端口号): Max retries exceeded with url: url路径 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x106831310>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',)) 网上解决方法:不使用python的DNS解析标准库,使用gevent内置的取代标准库的DNS解析模块.

  • Windows环境下无法实践开发者模式(httpbin的meinheld依赖无法安装)

    Windows环境下无法实践开发者模式(httpbin的meinheld依赖无法安装)

    安装环境:win10+python3.6 安装时出现下面的提示,安装版本与我的环境不匹配

    [email protected] MINGW64 ~/HttpRunner (master) $ pipenv install --dev Creating a virtualenv for this project... Pipfile: C:\Users\asus\HttpRunner\Pipfile Using d:\python\python36\python.exe (3.6.5) to create virtualenv... Already using interpreter d:\python\python36\python.exe Using base prefix 'd:\python\python36' New python executable in C:\Users\asus.virtualenvs\HttpRunner-gHQkxH18\Scripts\python.e xe Installing setuptools, pip, wheel...done. Setting project for HttpRunner-gHQkxH18 to C:\Users\asus\HttpRunner

    Virtualenv location: C:\Users\asus.virtualenvs\HttpRunner-gHQkxH18 Installing dependencies from Pipfile.lock (64c12a)... Ignoring enum34: markers 'python_version < "3"' don't match your environment Ignoring ipaddress: markers 'python_version < "3"' don't match your environment An error occurred while installing meinheld==0.6.1! Will try again. Ignoring ruamel.ordereddict: markers 'platform_python_implementation == "cpython" and py thon_version <= "2.7"' don't match your environment Installing initially failed dependencies... Collecting meinheld==0.6.1 Using cached https://files.pythonhosted.org/packages/6c/b7/0a6f03ba8e12862c71a7acc0c05 1f902f952f13be2a48878ebd2bc198562/meinheld-0.6.1.tar.gz Complete output from command python setup.py egg_info: Are you really running a posix compliant OS ? Be posix compliant is mandatory

  • UnicodeEncodeError: 'ascii' codec can't encode characters in position 11-13: ordinal not in range(128)

    UnicodeEncodeError: 'ascii' codec can't encode characters in position 11-13: ordinal not in range(128)

    运行测试用例后报以下错误,应该是字符编码处理有问题,因为返回结果里包含中文

    ERROR [0.133801s]: /user/init
    ----------------------------------------------------------------------
    Traceback (most recent call last):
    UnicodeEncodeError: 'ascii' codec can't encode characters in position 11-13: ordinal not in range(128)
    
    ----------------------------------------------------------------------
    Ran 2 tests in 0.375s
    
    FAILED
     (Errors=1)
    
    Generating HTML reports...
    Template is not specified, load default template instead.
    
  • 若对YAML格式不熟悉,推荐使用JSON格式编写维护测试用例

    若对YAML格式不熟悉,推荐使用JSON格式编写维护测试用例

    你好, 我使用python脚本调用ate部分,执行后报keyerror: 服务端返回值应该是如下:

    {
      "statusString": "MUSS Request Successful",
      "id": "3ffd3ab1-6781-4fdd-808a-03fa48e7d5ec||f00c8366-fb7e-401f-9a33-8c7280f12044:f00c8366-fb7e-401f-9a33-8c7280f12044",
      "extension": [
        {
          "streamURL": "rtsp://159.99.251.223:554/5e551f88-d852-4106-9f57-d3377227d545_1_1.sdp||rtmps://159.99.251.223:790/live/5e551f88-d852-4106-9f57-d3377227d545_1_1_28b0efd8-4a6c-40f5-9dcf-f4c67146adaf",
          "name": "isomStreamResponseStatus"
        }
      ]
    }
    

    脚本报错:

    Traceback (most recent call last):
      File "C:\Users\e567802\AppData\Local\Programs\Python\Python36\lib\site-packages\ate\utils.py", line 125, in query_json
        json_content = json_content[key]
    KeyError: 'extension'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "C:\Projects\PythonProject\APITest.py", line 8, in <module>
        APITest.run(testcase_path)
      File "C:\Users\e567802\AppData\Local\Programs\Python\Python36\lib\site-packages\ate\runner.py", line 198, in run
        result = self._run_testset(testset, mapping)
      File "C:\Users\e567802\AppData\Local\Programs\Python\Python36\lib\site-packages\ate\runner.py", line 171, in _run_testset
        assert self._run_test(testcase)
      File "C:\Users\e567802\AppData\Local\Programs\Python\Python36\lib\site-packages\ate\runner.py", line 118, in _run_test
        extracted_variables_mapping = resp_obj.extract_response(extract_binds)
      File "C:\Users\e567802\AppData\Local\Programs\Python\Python36\lib\site-packages\ate\response.py", line 77, in extract_response
        extracted_variables_mapping[key] = self.extract_field(field)
      File "C:\Users\e567802\AppData\Local\Programs\Python\Python36\lib\site-packages\ate\response.py", line 51, in extract_field
        return utils.query_json(json_content, sub_query)
      File "C:\Users\e567802\AppData\Local\Programs\Python\Python36\lib\site-packages\ate\utils.py", line 130, in query_json
        raise exception.ParseResponseError("failed to query json when extracting response!")
    ate.exception.ParseResponseError: failed to query json when extracting response!
    
    

    我脚本中的调用:

    from ate.runner import Runner
    from ate import utils
    
    if __name__ == '__main__' :
        #utils.SECRET_KEY='BaseTest'
        testcase_path='Test_Cases/Stream/'
        APITest=Runner()
        APITest.run(testcase_path)
    

    请问是什么问题呢?

    另外,询问下,我想改默认的debugtalk.py为BaseTest.py应该怎么设置?

    谢谢。

  • 使用hrp convert xxx.har --to-yaml返回response body is not json, not matched with MimeType 错误

    使用hrp convert xxx.har --to-yaml返回response body is not json, not matched with MimeType 错误

    使用hrp convert xxx.har --to-yaml转换HAR文件,如果某个HTTP响应mimeType是application/json,但response.content.text内容为'[]'或者'[{key1:value1}, {key2:value2}]'会触发这个异常 https://github.com/httprunner/httprunner/blob/2a7d9ebde2ce6240cefd0a303ac0e46873b923e2/hrp/pkg/convert/from_har.go#L594

  • 大的请求体被添加CRLF换行,导致请求失败

    大的请求体被添加CRLF换行,导致请求失败

    4.3.0版本 windows环境

    使用hrp run的运行方式。 postdata为json,接口一直返回400(400 Bad Request) 把控制台打印的请求体copy到notepad++查看,发现json里面被添加了很多CRLF的换行符, 导致请求返回400 65b22a2ad31de9463d6611554996b23

    用python的requests试了下,没有问题。 不知道go发请求的时候做了啥~~~

  • 关于v3和v4测试用例的结构

    关于v3和v4测试用例的结构

    问题描述

    HttpRunner 版本 4.3.0 目前,从v3开始,因为弱化了api层。 testcase的组织固定死了(确切地说是request跟variable和validate绑在一起了):variable + request + validate + 其他 我的问题是,假设一个接口正常返回的是 { "access_token": "abcdefg", "refresh_token":"" } 异常返回的是: { "msg": "somgthing went rong", "code": 401, "data": null } 也就是正常情况和异常情况返回的response结构完全不一样。 这样我只能写两个testcase来测这两种情况。如果接口信息改了,我得改两个地方。

    建议: 保留api层,只不过相比于v2, api文件只保留request相关的东西(api文件只保留接口的定义,不需要可以执行)。 testcase引用api的时候, 根据传入的variable 来决定validate 的结构和内容,还有extract,export那些。 这样,api的改动, 我才只需要改一个地方。

  • pytest执行用例,当jmespath获取数据异常,用例执行结果判断为成功

    pytest执行用例,当jmespath获取数据异常,用例执行结果判断为成功

    问题描述

    pytest执行用例,当jmespath获取数据异常,step报错,但是用例执行结果是成功的

    版本信息

    请提供如下版本信息:

    • 操作系统类型: [macOS]
    • Python 版本: [3.9]
    • HttpRunner 版本 [4.3.0]

    项目文件内容(非必须)

    image

    如果可能,提供项目测试用例文件原始内容可加快 bug 定位和修复速度。

    提示:请注意在去除项目敏感信息(IP、账号密码、密钥等)后再进行上传。

  • httprunner V4.3.0 转换测试用例时出现没有安装black的报错

    httprunner V4.3.0 转换测试用例时出现没有安装black的报错

    问题描述

    httprunner V4.3.0 转换测试用例时出现没有安装black的报错 尽量附带运行的命令和报错时的堆栈信息 (venv) C:\Users\talen\PycharmProjects\httpRunner_Test>hrp convert demo/testcases/data.har --venv C:\Users\talen\PycharmProjects\httpRunner_Test\venv --to-pytest 11:24AM INF Set log to color console 11:24AM ??? Set log level 11:24AM INF ensure python3 venv packages=["httprunner==v4.3.0"] python3="C:\Users\talen\PycharmProjects\httpRunner_Test\venv\Scripts\python.exe" 11:24AM INF python package is ready name=httprunner version=v4.3.0 11:24AM INF set python3 executable path Python3Executable="C:\Users\talen\PycharmProjects\httpRunner_Test\venv\Scripts\python.exe" 11:24AM INF load file path=demo/testcases/data.har 11:24AM INF convert teststep method=GET url=http://chandao.shushangyun.com/index.php?m=bug&f=view&bugID=28210 11:24AM INF convert teststep method=GET url=http://chandao.shushangyun.com/theme/default/zh-cn.default.css?v=12.3 11:24AM INF convert teststep method=GET url=http://chandao.shushangyun.com/js/all.js?v=12.3 11:24AM INF convert teststep method=GET url=http://chandao.shushangyun.com/js/kindeditor/kindeditor.min.js?v=12.3 11:24AM INF convert teststep method=GET url=http://chandao.shushangyun.com/js/kindeditor/lang/zh_CN.js?v=12.3 11:24AM INF convert teststep method=GET url=http://chandao.shushangyun.com/index.php?m=file&f=read&t=png&fileID=60613 11:24AM INF convert teststep method=GET url=http://chandao.shushangyun.com/index.php?m=file&f=read&t=png&fileID=60612 11:24AM INF convert teststep method=GET url=http://chandao.shushangyun.com/js/jquery/syntaxhighlighter/styles/shCore.css?v=12.3 11:24AM INF convert teststep method=GET url=http://chandao.shushangyun.com/js/jquery/syntaxhighlighter/styles/shThemeDefault.css?v=12.3 11:24AM INF convert teststep method=GET url=http://chandao.shushangyun.com/js/jquery/syntaxhighlighter/scripts/shCore.js?v=12.3 11:24AM INF convert teststep method=GET url=http://chandao.shushangyun.com/js/jquery/syntaxhighlighter/scripts/shAutoloader.js?v=12.3 11:24AM INF convert teststep method=GET url=http://chandao.shushangyun.com/theme/zui/fonts/ZentaoIcon.woff?v=1.1.0 11:24AM INF convert teststep method=GET url=http://chandao.shushangyun.com/js/kindeditor//kindeditor.min.css 11:24AM INF convert teststep method=GET url=http://chandao.shushangyun.com/theme/zui/css/min.css 11:24AM INF convert teststep method=GET url=https://ssl.google-analytics.com/ga.js 11:24AM INF convert teststep method=GET url=http://chandao.shushangyun.com/favicon.ico 11:24AM INF dump data to json path="C:\Users\talen\PycharmProjects\httpRunner_Test\demo\testcases\data_test.json" 11:24AM INF exec command cmd="C:\Windows\system32\cmd.exe" 2022-10-28 11:24:10.839 | INFO | make path: C:\Users\talen\PycharmProjects\httpRunner_Test\demo\testcases\data_test.json 2022-10-28 11:24:10.846 | INFO | ensure compatibility with testcase format v2/v3 2022-10-28 11:24:10.850 | INFO | Loading environment variables from C:\Users\talen\PycharmProjects\httpRunner_Test\demo.env 2022-10-28 11:24:10.853 | INFO | start to make testcase: C:\Users\talen\PycharmProjects\httpRunner_Test\demo\testcases\data_test.json 2022-10-28 11:24:10.855 | INFO | generated testcase: C:\Users\talen\PycharmProjects\httpRunner_Test\demo\testcases\data_test_test.py 2022-10-28 11:24:10.855 | INFO | format pytest cases with black ... 2022-10-28 11:24:10.862 | ERROR | missing dependency tool: black install black manually and try again: $ pip install black

    11:24AM ERR exec command failed error="exit status 1" 11:24AM ERR convert case failed error="exit status 1" input sample=demo/testcases/data.har 11:24AM INF conversion completed output files=[]

    版本信息

    请提供如下版本信息:

    • 操作系统类型: [Windows11]
    • Python 版本: [3.7]
    • HttpRunner 版本 [e.g. 4.3.0]

    项目文件内容(非必须)

    satrtproject生成的demo.har 转 py文件 hrp convert demo/testcases/data.har --venv C:\Users\talen\PycharmProjects\httpRunner_Test\venv --to-pytest

    在虚拟环境venv下,我用pip list确认了black已安装(甚至手动安装最新版本的black) image

    目前我下载了仓库中的4.3.0编译产物转测试用例,出现报错。 image

    但是用4.2.0的转测试用例,可以转换成功。 image

go websocket client for unit testing of a websocket handler

wstest A websocket client for unit-testing a websocket server The gorilla organization provides full featured websocket implementation that the standa

Nov 27, 2022
HTTP mock for Golang: record and replay HTTP/HTTPS interactions for offline testing

govcr A Word Of Warning I'm in the process of partly rewriting govcr to offer better support for cassette mutations. This is necessary because when I

Nov 23, 2022
Expressive end-to-end HTTP API testing made easy in Go

baloo Expressive and versatile end-to-end HTTP API testing made easy in Go (golang), built on top of gentleman HTTP client toolkit. Take a look to the

Nov 19, 2022
End-to-end HTTP and REST API testing for Go.

httpexpect Concise, declarative, and easy to use end-to-end HTTP and REST API testing for Go (golang). Basically, httpexpect is a set of chainable bui

Dec 4, 2022
HTTP mocking to test API services for chaos scenarios
HTTP mocking to test API services for chaos scenarios

GAOS HTTP mocking to test API services for chaos scenarios Gaos, can create and provide custom mock restful services via using your fully-customizable

Nov 5, 2022
Golang HTTP client testing framework

flute Golang HTTP client testing framework Presentation https://speakerdeck.com/szksh/flute-golang-http-client-testing-framework Overview flute is the

Sep 27, 2022
http integration test framework

go-hit hit is an http integration test framework written in golang. It is designed to be flexible as possible, but to keep a simple to use interface f

Nov 27, 2022
Extremely flexible golang deep comparison, extends the go testing package and tests HTTP APIs
Extremely flexible golang deep comparison, extends the go testing package and tests HTTP APIs

go-testdeep Extremely flexible golang deep comparison, extends the go testing package. Latest news Synopsis Description Installation Functions Availab

Nov 26, 2022
Record and replay your HTTP interactions for fast, deterministic and accurate tests

go-vcr go-vcr simplifies testing by recording your HTTP interactions and replaying them in future runs in order to provide fast, deterministic and acc

Dec 1, 2022
HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽

gock Versatile HTTP mocking made easy in Go that works with any net/http based stdlib implementation. Heavily inspired by nock. There is also its Pyth

Dec 1, 2022
HTTP mocking for Golang

httpmock Easy mocking of http responses from external resources. Install Currently supports Go 1.7 - 1.15. v1 branch has to be used instead of master.

Nov 29, 2022
Mock object for Go http.ResponseWriter

mockhttp -- Go package for unit testing HTTP serving Unit testing HTTP services written in Go means you need to call their ServeHTTP receiver. For thi

Sep 27, 2022
HTTP load testing tool and library. It's over 9000!
HTTP load testing tool and library. It's over 9000!

Vegeta Vegeta is a versatile HTTP load testing tool built out of a need to drill HTTP services with a constant request rate. It can be used both as a

Dec 4, 2022
HTTP load generator, ApacheBench (ab) replacement, formerly known as rakyll/boom
HTTP load generator, ApacheBench (ab) replacement, formerly known as rakyll/boom

hey is a tiny program that sends some load to a web application. hey was originally called boom and was influenced from Tarek Ziade's tool at tarekzia

Nov 28, 2022
Fast cross-platform HTTP benchmarking tool written in Go

bombardier bombardier is a HTTP(S) benchmarking tool. It is written in Go programming language and uses excellent fasthttp instead of Go's default htt

Nov 30, 2022
go-wrk - a HTTP benchmarking tool based in spirit on the excellent wrk tool (https://github.com/wg/wrk)

go-wrk - an HTTP benchmarking tool go-wrk is a modern HTTP benchmarking tool capable of generating significant load when run on a single multi-core CP

Nov 28, 2022
Fast HTTP enumerator
Fast HTTP enumerator

monsoon A fast HTTP enumerator that allows you to execute a large number of HTTP requests, filter the responses and display them in real-time. Example

Nov 26, 2022
Lightweight HTTP mocking in Go (aka golang)

httpmock This library builds on Go's built-in httptest library, adding a more mockable interface that can be used easily with other mocking tools like

Nov 2, 2022
a benchmarking&stressing tool that can send raw HTTP requests

reqstress reqstress is a benchmarking&stressing tool that can send raw HTTP requests. It's written in Go and uses fasthttp library instead of Go's def

Nov 17, 2022