java+mock模拟接口参数

使用java -jar moco-runner-0.11.0-standalone.jar http -p [自己定端口号例如:8833] -c [自己建立的json文件]
[
  {
    "description": "首页",
    "request": {
      "uri": "/index",
      "method": "get"
    },
    "response": {
      "status": 200,
      "text": "Welcome to the the home page"
    }
  },
  {
    "description": "个人主页",
    "request": {
      "uri": "/userhomepage",
      "method": "get",
      "queries": {
        "userid": "3882",
        "name": "lucy"
      }
    },
    "response": {
      "status": 200,
      "headers": {
        "Content-Type": "application/json;charset=UTF-8"
      },
      "json": {
        "code": "10000",
        "message": "进入个人主页成功",
        "data": {
          "name": "lucy",
          "age": "19",
          "addr": "beijing",
          "tel": "15512348888",
          "lastlogin": "2020-10-01 10:55:23"
        }
      }
    }
  },
  {
    "description": "登录,请求Content-Type:application/json",
    "request": {
      "uri": "/login",
      "method": "post",
      "headers": {
        "Content-Type": "application/json"
      },
      "json": {
        "username": "admin",
        "password": "123456"
      }
    },
    "response": {
      "status": 200,
      "headers": {
        "Content-Type": "application/json"
      },
      "json": {
        "code": "10000",
        "message": "登录成功",
        "data": {
          "userid": "3882",
          "name": "lucy",
          "addr": "chengdu",
          "tel": "13355556666"
        }
      }
    }
  },
  {
    "description": "商品详情页,请求Content-Type:multipart/form-data",
    "request": {
      "uri": "/details",
      "method": "post",
      "forms": {
        "goodid": "1",
        "date": "20220101"
      }
    },
    "response": {
      "status": 200,
      "headers": {
        "Content-Type": "application/json;charset=UTF-8"
      },
      "json": {
        "goodid": "1",
        "name":"pears",
        "status":"1",
        "stock":"25",
        "vip_amount ":"24",
        "sale_amount":"18",
        "market_amount":"23.6",
        "attribute_value":"丰富营养",
        "product_attr_vals":"单果300g",
        "share_title":"分享标题",
        "share_descrip":"分享描述",
        "license":"营业执照",
        "employType":0
      }
    }
  },
  {
    "description": "订单详情页,请求Content-Type:application/x-www-form-urlencoded",
    "request": {
      "uri": "/order",
      "method": "post",
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded",
        "token": "mocktoken9gd878ad"
      },
      "forms": {
        "ordernum": "20201010",
        "userid": "3218"
      }
    },
    "response": {
      "status": 200,
      "headers": {
        "Content-Type": "application/json;charset=UTF-8"
      },
      "json": {
        "orderNo": "LO20111216292785711001",
        "productId":2,
        "skuId":2,
        "expert":0,
        "count":1,
        "payType":"WECHAT_PAY",
        "payClient":"MINI",
        "mobile":"15812345678",
        "goodname":"apple",
        "orderType":"NORMAL",
        "logistics":"NONE"
      }
    }
  },
  {
    "description": "物流详情,请求Content-Type:application/json,必须加上token才能访问",
    "request": {
      "uri": "/logistics",
      "method": "post",
      "headers": {
        "Content-Type": "application/json",
        "token": "mocktoken9gd878ad"
      },
      "json": {
        "LogisticCode": "118461988807",
        "ShipperCode": "SF"
      }
    },
    "response": {
      "status": 200,
      "headers": {
        "Content-Type": "application/json;charset=UTF-8"
      },
      "json": {
        "EBusinessID": "1109259",
        "OrderCode": "1",
        "ShipperCode": "SF",
        "LogisticCode": "118461988807",
        "Success": true,
        "CallBack": "",
        "State": 3,
        "Reason": null,
        "Traces": [
          {
            "AcceptTime": "2014/06/25 08:05:37",
            "AcceptStation": "正在派件..(派件人邓裕富,电话:18718866310)[深圳市]",
            "Remark": "超时1小时"
          },
          {
            "AcceptTime": "2014/06/25 04:01:28",
            "AcceptStation": "快件在深圳集散中心,准备送往下一站深圳[深圳市]",
            "Remark": null
          },
          {
            "AcceptTime": "2014/06/25 01:41:06",
            "AcceptStation": "快件在深圳集散中心[深圳市]",
            "Remark": null
          },
          {
            "AcceptTime": "2014/06/24 20:18:58",
            "AcceptStation": "已收件[深圳市]",
            "Remark": null
          },
          {
            "AcceptTime": "2014/06/24 20:55:28",
            "AcceptStation": "快件在深圳,准备送往下一站深圳集散中心[深圳市]",
            "Remark": null
          },
          {
            "AcceptTime": "2014/06/25 10:23:03",
            "AcceptStation": "派件已签收[深圳市]",
            "Remark": null
          },
          {
            "AcceptTime": "2014/06/25 10:23:03",
            "AcceptStation": "签收人是:已签收[深圳市]",
            "Remark": "送货上门签收"
          }
        ]
      }
    }
  },
  {
    "description": "这是一个带cookie信息的get请求",
    "request": {
      "uri": "/getcookie",
      "method": "get"


    },
    "response": {
      "cookies": {
        "login": "true"

      },
      "text": "恭喜你获得cookies信息",
      "headers": {
        "Content-Type": "text/html;charset=gbk"
      }

    }
  },
  {
    "description": "这是一个带cookies信息的get请求",
    "request": {
      "uri": "/get/with/cookies",
      "method": "get",
      "cookies":{
        "login": "true"

      }
    },
    "response": {
      "text": "这是一个需要携带cookie才能带的get请求",
      "headers": {
        "Content-Type": "text/html;charset=gbk"
      }
    }
  },
  {
    "description": "这是一个带cookies信息的post请求",
    "request": {
      "uri": "/post/with/cookies",
      "method": "post",
      "cookies": {
        "login": "true"
      },
      "json": {
        "name": "huhansan",
        "age": 18
      }
    },
    "response": {
      "status": 200,
      "json": {
        "huhansan": "success",
        "status": 1
      }
    }
  }
]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值