Moco配置
一、下载
moco下载地址
http://repo1.maven.org/maven2/com/github/dreamhead/moco-runner/
二、启动
前提:①、配置好Java环境 ②、下载moco-runner-0.10.0-standalone.jar
启动命令:java -jar moco-runner-0.10.0-standalone.jar http/start -p 2256 -c demo.json
启动成功后,在浏览器输入 http://localhost:2256 or http://127.0.0.1:2256即可访问
参数说明:
p: (port)端口号
c:(config)配置文件
其他:
1、命令执行目录必须在moco的jar所在路径
2、config文件和jar放在同一目录下
3、返回中文乱码的解决方式:在启动moco-runner的时候,设置字符编码方式为utf-8
java -Dfile.encoding=utf-8 -jar moco-runner-0.10.0-standalone.jar start -p 4416 -c demo_post_others.json
Postman
一、json请求
1、在header中添加对应头信息:
选择“Headers”→填写“Key”:Content-Type;填写“Value”:application/json,
或者点击“Bulk Edit”进入编辑模式,填写:Content-Type: application/json
2、添加参数信息
选择“Body”→点击“Raw”,以json的格式填写请求的参数:
{
"name":"John",
"age":5
}