用moco工具mock接口

 1.下载moco  jar包,下载地址:https://repo1.maven.org/maven2/com/github/dreamhead/moco-runner/0.11.0/

2.创建Json文件mock接口

3.运行命令

java -jar ./moco-runner-0.11.0-standalone.jar 协议 -p 端口号 -c 文件名.json

协议:一般是http,如果用到其他的协议填写对应的即可

端口号:随便写,比如8888

文件名.json:创建的json文件名

4.用浏览器或jmeter等相关工具验证是否正确

5.带参数的get请求与post请求的不同之处:get用queries  post用forms

[

{
    "description": "模拟一个有参数的get请求",
    "request": {
        "uri": "/getwithparam",
        "method": "get",
        "queries": {
            "name": "huhansan",
            "age": "18"
        }
    },
    "response": {
        "text": "这是一个有参数的get request"
    }
},
{
    "description": "模拟一个有参数的get请求",
    "request": {
      "uri": "/postwithparam",
      "method": "post",
      "forms": {
        "name": "huhansan",
        "sex": "man"
      }
    },
    "response": {
      "text": "这是一个有参数的post request"
    }
  }
]
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值