HAF

GNU General Public License v3.0
Python
windows, linux
TTL · 2019年01月17日 · 222 次阅读 · 0 条评论

How to get it

using pip to get it

tsbxmw@ps# pip install haf --upgrade

using git tool to get it

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

How to run

case template

py template

from haf.mark import test, skip, parameterize
from haf.case import BaseCase


class TestHello(BaseCase):

@test("test hello11")
def test_1(self):
assert 1+1 == 2
assert 1 == 5

@skip
@test("test hello12")
def test_2(self):
assert 1 + 1 == 2

@parameterize([{"test":123},{"test":245}])
def test_3(self, params):
print(params)
assert 1 + 1 == 2

@parameterize([{"test":123},{"test":245}])
def test_4(self, params):
assert params.get("test")==123

json template

{
"testcases": [
{
"id": 1,
"name": "GetCityWeather",
"subid": 1,
"subname": "default",
"api_name": "default",
"run": true,
"method": "get",
"protocol": "http",
"host_port": "t.weather.sojson.com",
"url": "/api/weather/city/101030100",
"request_data": "{}",
"request_header": "{}",
"sql_response_check_list": "None",
"sql_response": "None",
"response": "json",
"expect_response": "{\"123\":123123}",
"response_exclude": "None",
"description": "default with no params",
"story": "Default with no params",
"sql_config": "None",
"sql_setup": "None",
"sql_teardown": "None",
"sql_get_result": "None",
"expect_sql": "None",
"dependent": null
}
],
"dbconfig": [{
"id": 1,
"sql_name": "mysql1",
"protocol": "mysql",
"host": "192.168.41.208",
"port": 3306,
"username": "root",
"password": "testzhan123",
"database": "visual"
}, {
"id": 2,
"sql_name": "192.168.41.102",
"protocol": "sqlserver",
"host": "192.168.41.102",
"port": 1433,
"username": "uat",
"password": 111111,
"database": "ERP_DB"
}, {
"id": 3,
"sql_name": "mysql2",
"protocol": "mysql",
"host": "192.168.41.68",
"port": 3306,
"username": "xztest",
"password": "nC0Dq1xDH6uq[K1of0V1",
"database": "corpus_qa"
}],
"config": [{
"name": "test2",
"benchname": "test2",
"protocol": "http",
"host_port": "t.weather.sojson.com"
}]
}

local bus mode, using local bus to run all cases

  • local bus is without --bus-server(-bs) args, when running the program, the bus would be created
modify the config.json in testcases
  • change the log_path and report_path and case_path to your own path
{
"config":{
"run": {
"log": {
"log_path": "D:/workspace/mine/python/haf/data"
},
"bus": {
"only": false,
"host": "",
"port": "",
"auth_key": ""
},
"report": {
"report_path": "D:/workspace/mine/python/haf/data/report.html"
},
"case": [
{
"case_path": "D:/workspace/mine/python/haf/testcases/test.xlsx"
},
{
"case_path": "D:/workspace/mine/python/haf/testcases/test2.json"
},
{
"case_path": "D:/workspace/mine/python/haf/testcases/test1.xlsx"
},
{
"case_path": "D:/workspace/mine/python/haf/testcases/test3.yml"
},
{
"case_path": "D:/workspace/mime/python/haf/testcases/test4.py"
}
],
"runner":{
"only": false,
"count": 4
},
"loader": {
"only": false
},
"recorder": {
"only": false
},
"web_server": {
"host": "",
"port": "",
"run": true
}
}
}

}
create testcase
  • create xlsx/json/yml file with template in testcases/
run
  • run with config
python -m haf run -c=./testcases/config.json
  • run with args
python -m haf run -case=./testcases/test.xlsx,./testcases/test2.json -ld=./data -rh=true -rod=./data/report.html
other run args
  • run with multi-runners (4 runners)
python -m haf run -rc=4
  • run with web server
python -m haf run -ws=true
  • run with only-mode
# 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
评论列表
暂无评论.