一.moco模拟接口响应json
moco的下载地址见虫师博客园:https://www.cnblogs.com/fnng/p/7511539.html
foo.json文件内容如下
[ { "description":"模拟一个post请求", "request":{ "uri":"/postdemo", "method":"post" }, "response":{ "status":200, "json":{ "success":true, "errorCode":"", "errorMsg":"" } } } ]
启动moco-runner后,用postman访问接口,响应实例如下:
二.moco模拟接口响应xml
foo.json内容如下
[{ "description": "模拟一个post请求", "request": { "uri": "/postdemo", "method": "post" }, "response": { "status": 200, "file": "a.xml" } }]
a.xml文件中内容如下:
<?xml version="1.0" encoding="UTF-8"?><request><success>true</success><errorCode></errorCode><errorMsg></errorMsg></request>
启动moco-runner后,用postman访问接口,响应实例如下: