支持多种测试的高可用测试框架
tsbxmw@ps# pip install haf --upgrade
tsbxmw@ps# git clone https://github.com/tsbxmw/haf
tsbxmw@ps# cd haf
tsbxmw@ps# python setup.py install
python -m haf init
或者
git clone https://github.com/tsbxmw/haf-sample
python -m haf run -c=config.json
python -m haf run -c=config-web.json
使用 `chrome` 或者其他浏览器打开即可。
快速开始 | 例子 | pypi 主页 | 文档主页 |
---|---|---|---|
开始 | haf-sample | pypi | doc |
id | 插件名称 | 插件版本 | github 主页 |
---|---|---|---|
1 | haf api server | haf webserver | |
2 | haf sql publish | haf sqlpublish |
--bus-server(-bs)
参数不适用时便是本地模式
- 修改
log_path
和report_path
和case_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
}
}
}
}
- 创建
xlsx/py/json/yaml
格式的用例 - 也可以使用
haf-sample
中的例子
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
- 更改
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"
}
}
- 更改
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"
}
}
- 使用多个 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"
}
tsbx# pip install hafweb -U
python -m hafweb -ss=root:root@localhost:3306@haf_publish -p=8081
-
默认页面
-
index page
-
today page
-
others support looking at hafweb project
- 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
-
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