No postman or jmeter, how do interface testing?

 I think of a question: If there is no Postman, no jmeter, can not be happy to do interface testing?     The answer of course - you can!    Old driver today to recommend a universal interface testing tool curl.     curl, is a command-line tool that does not rely on any interface, consistent performance on various operating systems, Windows and seamlessly switch Linux.
    Linux system comes with curl tool, you need to download the Windows to configure it.
    Today the old drivers tell you about how to configure Windows environment curl. 1, download the curl tool to directly access the Windows platform curl download tool site : https: //curl.haxx.se/windows/








 

 

According to his own version of Windows, 32-bit or 64-bit find download.
A compressed package downloaded to the local.

 

 

 

 


After unpacking, a directory, change the name into a location, such as the old driver put the c: curl-7.67.0. Curl under the bin directory to the PATH environment variable, such as the old driver so.

 

 


    Verify the result, open a command line, enter curl -V command, out version information, then the installation was successful.

 

 





2, a simple experiment, visit web pages



, for example, access baidu home page.
Direct knock command, curl baidu.com. Return results directly to the contents pulling baidu home, and no error message.

 

 

        If you want to look at http response header, then the implementation of the -I curl  www.baidu.com  . (That argument uppercase i)

 

 

 

 





第3,复杂的http请求



模仿一个GET请求,比如访问 https://postman-echo.com/get?foo1=bar1&foo2=bar2执行命令:curl -X GET https://postman-echo.com/get?foo1=bar1&foo2=bar2

 

 

        -X 表示使用方法,后面跟着的GET表示,使用GET方法。
    运行命令后,输出的一大串是返回的JSON串。有兴趣的同学,可以找个Chrome浏览器,在地址栏输入https://postman-echo.com/get?foo1=bar1&foo2=bar2 试试看,效果一样的。
    再模仿一个POST请求,比如访问:https://postman-echo.com/post ,提交参数foo1=bar1, foo2=bar2

 

 


 

 

   返回值是一串结果JSON串。
    用Postman或者jmeter执行接口测试,效果也一样。    同理,在纯命令行模式,比如服务器Linux环境,curl命令参数一样的。
    Curl更高级用法,小伙伴们可以继续探索。
    老司机今天车先开到这里,下次再见!

作  者:Testfan Arthur
出  处:微信公众号:自动化软件测试平台
版权说明:欢迎转载,但必须注明出处,并在文章页面明显位置给出文章链接

Guess you like

Origin www.cnblogs.com/testfan2019/p/12426503.html