mock技术之moco
地址:https://github.com/dreamhead/moco,可以查看详细文档和源码
下载地址:https://repo1.maven.org/maven2/com/github/dreamhead/moco-runner/
选择需要的版本下载jar包,放入目录,例如D:\mock
foo.json文件配置接口信息,内容例如:
[
{
"description":"login接口",
"request":{
"uri":"/login",
"method":"POST",
"json":{
"user":"test",
"pwd":"1111111"
}
},
"response":{
"json":{
"status":"True",
"message":"success",
"data":"111"
}
}
},
{
"description":"test接口",
"request":{
"uri":"/test",
"method":"GET"
},
"response":{
"json":{
"status":"True",
"message":"success",
"data":"111"
}
}
}
]
执行命令:
java -jar moco-runner-1.4.0-standalone.jar http -p 8090 -c foo.json
即可启动
可以编辑一个bat文件方便每次启动,文件内容:
cd D:\mock
java -jar moco-runner-1.4.0-standalone.jar http -p 8090 -c foo.json