Moco Runner 构建mock测试服务器

2020/02/12

– layout: post title: moco-runner 构建mock测试服务器 category: Mysql tags: [测试] —

Moco is an easy setup stub framework.

下载

下载最新的JAR

这个下载有些慢,可以网盘获取:

链接:https://pan.baidu.com/s/1PzwGCcrWNwdn6R2Cpr11Xw 密码:t8rk

简单运行

java -jar moco-runner-0.12.0-standalone.jar http -p 9090 -c foo.json

foo.json

[
  {
    "response": {
      "text": "foo"
    }
  }
]

Post

JSON配置文件

[
  {
    "request": {
      "text": "foo"
    },
    "response": {
      "text": "bar"
    }
  },
  {
    "request": {
      "uri": "/json",
      "text": {
        "json": "{\"foo\":\"bar\"}"
      }
    },
    "response": {
      "text": "foo"
    }
  }
]

请求一:

POST http://localhost:9090/json  
Accept: */*  
Cache-Control: no-cache  
  
{"foo":"bar"}

响应一:

POST http://localhost:9090/json

HTTP/1.1 200 OK
Content-Length: 3
Content-Type: text/plain; charset=utf-8

foo

请求二:

GET http://localhost:9090  
Accept: */*  
Cache-Control: no-cache  
  
foo

响应二:

GET http://localhost:9090

HTTP/1.1 200 OK
Content-Length: 3
Content-Type: text/plain; charset=utf-8

bar

Bar启动

目录结构

启动命令

@echo off

java -jar [moco-runner-0.12.0-standalone.jar](moco-runner-0.12.0-standalone.jar) http -p 7890-c moco_data.json

echo server start success! port is 7890
pause

启动

更多用法参考


作者:Wuxinshui
出处:http://wuxinshui.github.io
版权归作者所有,转载请注明出处

Post Directory