haf, make autotest easy and better
支持多种测试的高可用测试框架
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
init
命令 或者 git
获取源码例子 python -m haf init
或者
git clone https://github.com/tsbxmw/haf-sample
api
和 web-ui
的测试用例api
用例 python -m haf run -c=config.json
web ui
测试用例 python -m haf run -c=config-web.json
data
文件夹下找到 index.html
,作为默认的 html 报告使用 `chrome` 或者其他浏览器打开即可。
快速开始 | 例子 | pypi 主页 | 文档主页 |
---|---|---|---|
开始 | haf-sample | pypi | doc |
id | 插件名称 | 插件版本 | github 主页 |
---|---|---|---|
1 | haf api server | haf webserver | |
2 | haf sql publish | haf sqlpublish |
--bus-server(-bs)
参数不适用时便是本地模式testcases
中的 config.json
文件,用来运行自己的用例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
}
}
}
}
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
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"
}
}
https://github.com/hautof/haf-sample
runner-count
python -m haf run -rc=4
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
默认页面
http://localhost:8081/
index page
http://localhost:8081/index
today page
http://localhost:8081/today
others support looking at hafweb project
http://localhost:8888/loader
http://localhost:8888/runner
http://localhost:8888/result
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