mock测试用的moco框架使用方法
Posted 清_澈
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mock测试用的moco框架使用方法相关的知识,希望对你有一定的参考价值。
官网:
https://github.com/dreamhead/mocohttps://github.com/dreamhead/moco
更多使用文档:
Quick Start
- Download Standalone Moco Runner
将 moco-runner-1.3.0-standalone.jar 下载文件放到本地目录,然后编写login.json文件
[
"description" :"带参数的post请求,返回json",
"request" :
"uri" : "/login",
"method" : "post",
"forms" :
"uname" : "aaa",
"pwd" : "111"
,
"response" :
"status":200,
"json":
"code": 0,
"loginTime": "2022-2-21 14:49",
"message": "登录成功!",
"result":
"addr": "127.0.0.1"
,
"description":"带header请求",
"request":
"uri": "/withHeader",
"method": "post",
"headers":
"content-type": "application/json"
,
"json":
"name": "xiaoming",
"age": "18"
,
"response":
"json":
"message":"success",
"status":"1"
,
"description":"带参数的get请求,p1,p2分别的参数1,参数2,名称可随便起,个数也可随便加",
"request":
"uri":"/wihtGetDemobyParam",
"method":"get",
"queries":
"p1":"hh",
"p2":"good"
,
"response":
"json":
"message":"success 成功!",
"status":"1"
]
cd到此目录执行命令启动
java -jar moco-runner-1.3.0-standalone.jar http -p 12306 -c login.json
postman请求测试一下,是否ok
ok,成功了,收工~
以上是关于mock测试用的moco框架使用方法的主要内容,如果未能解决你的问题,请参考以下文章