mock
一、mockServer
1.1、什么是mock
Mock---》替身 server--〉服务 测试替身的服务
1.2、不同角色对mock的使用场景
1.2.1、前端
前端已写好??,但是后端的接?没写好,那么前端程序员正确的姿势是什么?正确的姿势就是模拟后端。 现在前端程序员来模拟后端返回的产品列表的数据:
[
{
"request":
{
"method": "get",
"uri": "/products"
},
"response":
{
"json":{
"name": "asdfghjkl",
"type": "WEB",
"version": "V1.0.0",
"master": "chenli",
"description": "this is a test api"
}
}
}
]
启动命令:java -jar moco-runner-1.3.0-standalone.jar http -p 12306 -c product.json
1.2.2、后端
A给B服务?个?牌号,那么B返回?辆的其他信息
[ { "request": { "method": "post", "uri": "/parking", "json": { "park": "A888888" } }, "response": { "json": { "park": "A888888", "in": "2022-01-14 00:00:00", "out": "2022-01-14 08:00:00", "money": "$5", "master": "chenli" } } } ]
1.2.3、测试
在测试过程中没有数据那么
1、自己造数据
2、自己moco数据
[ { "request": { "method": "get", "uri": "/products" }, "response": { "json": [ { "name": "asdfghjkl", "type": "WEB", "version": "V1.0.0", "master": "chenli", "description": "this is a test api" }, { "name": "asdfghjkl", "type": "WEB", "version": "V1.0.0", "master": "chenli", "description": "this is a test api" } ] } } ]
什么是moco
https://github.com/dreamhead/moco
https://www.cnblogs.com/weke/articles/6859021.html