00f100 / phpatr
该软件包的最新版本(0.12.0)没有可用的许可信息。
将软件包打包到您的测试路由API REST,以在Jenkins中使用
0.12.0
2016-10-03 13:56 UTC
Requires
- php: >=5.5
- 00f100/phpuphar: *
- guzzlehttp/guzzle: 6.*
Requires (Dev)
- 00f100/phpdbug: *
- phpunit/phpunit: 4.*
README
打包到 烟雾测试
在基于JSON文件的Jenkins上测试您的API REST!
易于配置和安全的测试结果!
安装
$ wget https://raw.githubusercontent.com/00F100/phpatr/master/dist/phpatr.phar
或 下载Phar文件
配置
配置文件 "phpatr.json"
示例
{ "name": "Test reqres.in", "base": [ { "name": "httpbin.org", "url": "http://httpbin.org", "query": {}, "header": {} } ], "auth": [ { "name": "noAuth", "query":{}, "header": {}, "data": {} } ], "tests": [ { "name": "Test to get IP", "base": "httpbin.org", "auth": "noAuth", "path": "/ip", "method": "GET", "query": {}, "header": {}, "data": {}, "assert": { "type": "json", "code": 200, "fields": [ { "name": "origin", "type": "string" } ] } }, { "name": "Test to POST data", "base": "httpbin.org", "auth": "noAuth", "path": "/post", "method": "POST", "query": {}, "header": {}, "data": { "posttest": "95ddcb76ded165f81607e3f050070946" }, "assert": { "type": "json", "code": 200, "fields": [ { "name": "form", "type": "array", "fields": [ { "name": "posttest", "type": "string", "eq": "95ddcb76ded165f81607e3f050070946" } ] } ] } }, { "name": "Test not found 404", "base": "httpbin.org", "auth": "noAuth", "path": "/status/404", "method": "GET", "query": {}, "header": {}, "data": {}, "assert": { "code": 404 } }, { "name": "Test status teapot", "base": "httpbin.org", "auth": "noAuth", "path": "/status/418", "method": "GET", "query": {}, "header": {}, "data": {}, "assert": { "code": 418 } } ] }
用法
PHPatr version 0.7.0
Usage:
Test API REST:
php phpatr.phar --config <config file> [--output <file>, [--debug]]
Generate example JSON configuration:
php phpatr.phar --example-config-json
Self Update:
php phpatr.phar --self-update
Help:
php phpatr.phar --help
Options:
-d, --debug Debug the calls to API REST
-c, --config File of configuration in JSON to test API REST calls
-e, --example-config-json Generate a example file JSON to configuration
-o, --output Output file to save log
-u, --self-update Upgrade to the latest version version
-v, --version Return the installed version of this package
-h, --help Show this menu
如何
执行测试
$ php phpatr.phar --config <config file> [--output <file>, [--debug]]
Options:
-c, --config File of configuration in JSON to test API REST calls
-o, --output Output file to save log
-d, --debug Debug the calls to API REST
更新
$ php phpatr.phar --self-update
帮助
$ php phpatr.phar --help
示例 "执行测试" 返回成功
user@ubuntu /path/to/project> php phpatr.phar --config phpatr.json
[SLOG] Start: 2016-08-27 15:40:11
[SLOG] Config File: phpatr.json
[SLOG] Test Config: Test reqres.in
[SLOG] Run Tests!
[ OK ] Test users single vetor
[ OK ] Test users vector multilevel
[ OK ] Example error: Test users vector multilevel
[SLOG] End: 2016-08-27 15:40:12
示例 "执行测试" 返回错误
user@ubuntu /path/to/project> php phpatr.phar --config phpatr.json
[SLOG] Start: 2016-08-27 15:40:11
[SLOG] Config File: phpatr.json
[SLOG] Test Config: Test reqres.in
[SLOG] Run Tests!
[ OK ] Test users single vetor
[ OK ] Test users vector multilevel
[FAIL] Example error: Test users vector multilevel
[FLOG] The tests[]->assert->fields does not match to test
[SLOG] End: 2016-08-27 15:40:12
[FLOG] Test failed