首页 > 其他 > 详细

moco使用

时间:2017-07-19 11:34:37      阅读:284      评论:0      收藏:0      [点我收藏+]

1:下载安装jdk

2:下载mock jar包   moco-runner-0.10.0-standalone.jar  

3:启动mock  使用mock占用12300接口

需要cmd  dos环境却换到moco目录下执行以下语句:

java -jar moco-runner-0.10.0-standalone.jar  http -p 12300 -c config.json


接口的实现都是在config.json 的配置文件里实现。

可对接口进行模拟的实现

localhost:12300/***

也可写一些脚本对此接口进行测试

具体配置内容可为:

[

  {

    "request" :

      {

        "uri" : "/posts" ------

      },

    "response" :

      {

        "file" : "all_posts.json"

      }

  },

  {

    "request" :

      {

        "method": "get",   -----接口调用方式

        "uri" : "/posts/1"

      },

    "response" :

      {

        "file" : "post_1.json"

      }

  },

  {

    "request" :

      {

        "method": "get",

        "uri" : "/posts/2"

      },

    "response" :

      {

        "file" : "post_2.json"

      }

  },

  {

    "request" :

      {

        "method": "get",

        "uri" : "/posts/3"

      },

    "response" :

      {

        "file" : "post_3.json"

      }

  },

  {

    "request" :

      {

        "method": "get",

        "uri" : "/posts/3/comments"

      },

    "response" :

      {

        "file" : "post_3_comments.json"

      }

  }

]



moco使用

原文:http://xueba.blog.51cto.com/950993/1948751

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!