MOCO框架

Mock平台功能介绍

不仅可给自己使用,还可以给前端使用。

对于测试人员产出!非常重要!

Moco框架基本介绍

http协议

https://repo1.maven.org/maven2/com/github/dreamhead/moco-runner/0.11.0/

下载jar包 最大值

写一个基本操作说明

java -jar ./moco-runner-0.11.0-standalone.jar http  -p 8888 -c json配置文件

java -jar ./moco-runner-0.11.0-standalone.jar http  -p 8888 -c startup1.json//路径

同一个路径下

没有写方法 默认get

127.0.0.1:8888/demo

localhost:8888/demo

��һ��moco˵ 可能会乱码

带参数的get方法实现

queries{}

[

  {

    "description": "模拟一个没有参数的get请求",

    "request": {

      "uri": "/getdemo",

      "method": "get"

    },

    "response": {

      "text": "这是一个没有参数的get请求"

    }

  },

  {

    "description": "模拟一个带参数的get请求",

    "request": {

      "uri": "/getwithparam",

      "method": "get",

      "queries": {

        "name": "jane",

        "age": "18"

    }

    },

    "response": {

      "text": "这是一个with param 的get请求"

    }

  }

]

带参数的post方法

forms{}----form data

[

  {

    "description": "post request",

    "request": {

      "uri":"/postdemo",

      "method": "post"

    },

    "response": {

      "text": " the first mock post request"

    }

  },

  {

    "description": "post with param request",

    "request": {

      "uri": "/postwithparam",

      "method": "post",

      "forms": {

        "name": "jane",

        "age": "18"

      }

    },

    "response": {

      "text": "post with param come back"

    }

  }

]

加入cookies

添加域,路径,keyvalue

Cookie_2=value; path=/; domain=localhost;

[

  {

    "description": "带cookies的get请求",

    "request": {

      "uri": "/cookies/get",

      "method": "get",

      "cookies": {

        "login": "true"

      }

    },

    "response": {

      "text": "GET  with cookies "

    }

  },

  {

    "description": "带cookies的post请求",

    "request": {

      "uri": "/cookies/post",

      "method": "post",

      "cookies": {

        "login": "true"

      },

      "json": {

        "name": "jane",

        "age": "18"

      }

    },

    "response": {

      "status": 200,

      "json": {

        "name": "success",

        "status": "1"

      }

    }

  }

]

加入header信息

get和post一致的,都是 request中

[

  {

    "description": " post with header",

    "request": {

      "uri": "/post/headers",

      "method": "post",

      "headers": {

        "content-type": "application/json"

      },

      "json": {

        "name": "jane",

        "age": "18"

      }

    },

    "response": {

      "json": {

        "jane": "success",

        "status": "1"

      }

    }

  }

]

重定向

[

  {

    "description": "重定向到百度",

    "request": {

      "uri": "/redirect"

    },

    "redirectTo": "http://www.baidu.com"

  },

  {

    "description": "重定向到一个自己的网页上",

    "request": {

      "uri": "/redirect/topath"

    },

    "redirectTo": "/redirect/new"

  },

  {

    "description": "这是被重定向的请求",

    "request": {

      "uri": "/redirect/new"

    },

    "response": {

      "text": "重定向成功啦"

    }

  }

]

TIPS

1 热部署

就是在应用正在运行的时候升级软件,却不需要重新启动应用

就是已经运行了项目,更改之后,不需要重新tomcat,但是会清空内存,重新打包,重新解压war包运行

可能好处是一个tomcat多个项目,不必因为tomcat停止而停止其他的项目

只用修改配置文件就可以

2 Jmeter

有 cookie管理器

3 退出命令行

ctrl +c 退出 命令行 !

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 英文文档,一开始我也是抗拒的,边翻译边看,也就花费了1个小时基本就阅读过了,我的英文基础其实很差。附上链接:链接:...
    lonecolonel阅读 10,015评论 3 1
  • 一、什么是Moco:Moco 是一个搭建模拟服务器的工具,其支持 API 和独立运行两种方式,前者通常是在 jun...
    零下的雨阅读 4,468评论 6 6
  • 基本操作: java -jar ./moco-runner-0.11.0-standalone.jar [http...
    原来不语阅读 841评论 0 1
  • 日精进打卡 姓名:陈小飞 部门岗位:查验部 【日精进打卡第22天】 【知~学习】 一、修身:读大学 跑步 二、齐家...
    嘟嘟爸_7469阅读 137评论 0 0
  • 啊,感觉最近仿佛不知道自己想做啥,要做啥了。事情真的好多啊,最后一个考试月压力真的有点大了。 应该增加运动。 应该...
    Skyy_阅读 214评论 0 1