php API接口如何进行测试

WBOY
Release: 2016-06-06 20:22:46
Original
1819 people have browsed it

如题,php API接口如何进行测试,大家有什么方案

回复内容:

如题,php API接口如何进行测试,大家有什么方案

postman

可以使用PHPUnit对API进行测试 :PHPUnit在Windows下的配置及使用

chrome 拓展 DHC
如果你是用PHPStorm的话里面有自带的工具。

OSX 还有一个非常不错的选择是 paw

我一般是用google chrome的一个插件:postman来测试接口。。。

curl 命令

目前的工具链: shell + curl + jq + awk + sed + ... 总体还是要肉眼一个一个地去看结果, 但接口尚未固定也只好用写个简单的脚本随意测下吧?
后面稳定下来, 我会考虑使用 phpUnit/codeception 之类的以方便对测试结果的处理。

<code>access_token=$(curl -Ss -X POST "${baseUrl}/user/login" -H 'Content-Type:application/json' -d '{"email":"a@bcom","password":"c"}' \
    | jq . | sed -n '/access_token/p' | awk '{ print $2 }' | tr -d '", ')</code>
Copy after login

或者 yii2-rest

HaTTip.
Paw
paw功能更全更高级一点

chrome和Firefox也有对应的插件

如果在用 PHP Storm(Jetbrains 家产品):

<code>menu->Tools->Test RESTful Web Service</code>
Copy after login

推荐jmeter

工具级可以用jmeter,如果后期向框架或架构及发展可以用robot Framework+requestLibrary

Advanced REST Client

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!