MOCO框架

作者: 小笨笨的花花 | 来源:发表于2019-08-10 14:08 被阅读0次

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 退出 命令行 !

相关文章

  • Moco接口框架学习(http协议)

    1.简介 mock用来模拟接口的,本次学习mock用的是moco框架,moco框架是github上的一个开源项目,...

  • MOCO框架

    Mock平台功能介绍 不仅可给自己使用,还可以给前端使用。 对于测试人员产出!非常重要! Moco框架基本介绍 h...

  • 详解构建mock服务最方便的神器——Moco

    moco介绍 moco框架是github上的一个开源项目,可模拟http,https,Socket协议的mock操...

  • moco框架使用

    一、moco介绍 mock测试就是在测试过程中,对于某些不容易构造或者不容易获取的对象,用一个虚拟的对象来创建以便...

  • moco常用配置参数及使用

    moco简介 moco框架是github上的一个开源项目,本身支持API和独立运行两种方式。通过使用API,开发人...

  • mock平台

    Moco框架: 下载地址:repo1.maven.org/maven2/com/github/dreamhead/...

  • moco-runner框架方法使用分享!

    测试的前置往往离不开mock服务的调用 对于moco框架网上大多是下载一个jar包,开启一个moco服务,然后调用...

  • Mock-server模拟项目接口配置

    Mock-Server 一 下载地址 moco框架下载地址https://github.com/dreamhead...

  • Moco框架基本介绍

    Moco框架的简单介绍(这篇文章可能不会给你带来多大的益处,因为我自己本身也是在学习,希望对恰好了解的人有一个帮助...

  • Moco框架基本介绍

    基本操作: java -jar ./moco-runner-0.11.0-standalone.jar [http...

网友评论

    本文标题:MOCO框架

    本文链接:https://www.haomeiwen.com/subject/ftlrjctx.html