Skip to main content

No project description provided

Project description

HAF

支持多种测试的高可用测试框架

Build Status Documentation Status PyPI GitHub release

all

安装

使用 pip 直接安装

   tsbxmw@ps# pip install haf --upgrade

使用 git 下载源码安装

   tsbxmw@ps# git clone https://github.com/tsbxmw/haf
   tsbxmw@ps# cd haf
   tsbxmw@ps# python setup.py install

如何运行例子

1,使用 init 命令 或者 git 获取源码例子

    python -m haf init

或者

    git clone https://github.com/tsbxmw/haf-sample

2, 例子提供了 apiweb-ui 的测试用例

运行 api 用例

    python -m haf run -c=config.json

运行 web ui 测试用例

    python -m haf run -c=config-web.json

3, 可以在 data 文件夹下找到 index.html,作为默认的 html 报告

使用 `chrome` 或者其他浏览器打开即可。

其他内容

快速开始 例子 pypi 主页 文档主页
开始 haf-sample pypi doc

插件

id 插件名称 插件版本 github 主页
1 haf api server PyPI haf webserver
2 haf sql publish PyPI haf sqlpublish

如何运行自定义的用例

可以本地运行所以的用例

所有的进程在本地模式下都是在本机存在的

  • --bus-server(-bs) 参数不适用时便是本地模式

修改 testcases 中的 config.json 文件,用来运行自己的用例

  • 修改 log_pathreport_pathcase_path 3 个字段为自己默认的地址,分别为 日志路径、报告路径、用例路径。
  • 可以删除 config->run->sql_publish 字段,如果不需要将数据上传到数据库。
    {
      "config":{
        "name": "test",
        "debug" : false,
        "bus_server_port": 8801,
        "run": {
          "sql_publish": {
            "id": 1,
            "sql_name": "upload",
            "publish": true,
            "host": "192.168.0.200",
            "port": 3306,
            "username": "root",
            "password": "root",
            "database": "haf_publish",
            "protocol": "mysql"
          },
          "log": {
            "log_path": "./data"
          },
          "bus": {
            "only": false,
            "host": "",
            "port": "",
            "auth_key": ""
          },
          "report": {
            "report_path": "./data/report.html",
            "report_template": "base",
            "report_export_path": "email"
          },
          "case": [
            {
              "case_path": "./testcases/test.xlsx"
            },
            {
              "case_path": "./testcases/test2.json"
            },
            {
              "case_path": "./testcases/test1.xlsx"
            },
            {
              "case_path": "./testcases/test3.yml"
            }
          ],
          "runner":{
            "only": false,
            "count": 4
          },
          "loader": {
            "only": false
          },
          "recorder": {
            "only": false
          },
          "web_server": {
            "host": "",
            "port": "",
            "run": true
          }
        }
      }
    }

可以使用 testcases 中提供的默认例子创建新的用例

  • 创建 xlsx/py/json/yaml 格式的用例
  • 也可以使用 haf-sample 中的例子

运行

使用 config 配置运行 测试

    python -m haf run -c=./testcases/config.json

使用 参数 运行测试

    python -m haf run -case=./testcases/test.xlsx,./testcases/test2.json -ld=./data -rh=true -rod=./data/report.html

测试报告

report

如何运行 app-ui 测试用例

  • 更改 config.json 中的 report 字段,增加 report_template 子字段, 使用 base_app 为模板
    "run": {
        "type": "app"  # change type to app

        "report": {
            "report_template": "base_app",  # change report_template to base_app
            "report_path": "./data/report.html"
        }
    }

report-app

运行 web-ui 测试用例

  • 更改 config.json 中的 report 字段,增加 report_template 子字段, 使用 base_web 为模板
    "run": {
        "type": "web"  # change type to web

        "report": {
            "report_template": "base_web",  # change report_template to base_web
            "report_path": "./data/report.html"
        }
    }

report-app

haf 例子

https://github.com/hautof/haf-sample

其他的命令行参数

  • 使用多个 runner 增加运行速度, runner-count
    python -m haf run -rc=4
  • 启动 web-server,提供可视化过程,web-server
    python -m haf run -ws=true
  • 只启动 loader/runner/bus/recorder 中的某个
    # only loader
    python -m haf run -ol=true
    # only bus
    python -m haf run -ob=true
    # only runner
    python -m haf run -or=true
    # only recorder
    python -m haf run -ore=true
  • 使用自定义的报告模板
    "report": {
        "report_template": "base_app"
    }
  • 使用插件将数据发送到 数据库
    "sql_publish": {
        "id": 1,
        "sql_name": "upload",
        "publish": true,
        "host": "192.168.0.200",
        "port": 3306,
        "username": "root",
        "password": "root",
        "database": "haf_publish",
        "protocol": "mysql"
    }

sql

其他支持

    tsbx# pip install hafweb -U
    python -m hafweb -ss=root:root@localhost:3306@haf_publish -p=8081

web api server suport

  • get loader infos
    http://localhost:8888/loader
  • get runner infos
    http://localhost:8888/runner
  • get result infos
    http://localhost:8888/result
  • get report infos
    http://localhost:8888/report
    http://localhost:8888/report-app

FrameWork

Design

map

Doc

doc url

read the doc

wiki home

Quick Start

Release Note

release note

new features

  • now support app-ui/web-ui cases and generate report

  • support mysql result publish

  • based on local test runners

  • support xlsx,json,yml,py cases

  • report generate with html-template

  • multi-processes on different machines

  • multi-runners

  • web-server support restful api based on flask

  • only mode : loader/runner/recorder/webserver/bus/logger support

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

haf-2.9.7-py2.py3-none-any.whl (542.6 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page