一、moco框架基本介绍
mock测试:mock测试就是在测试过程中,对于某些不容易构造或者不容易获取的对象,用一个虚拟的对象来创建以便测试的测试方法。一般可分为模拟调用方和被调用方2种方式。
mock用来模拟接口,这里mock用的是moco框架,moco框架是github上的一个开源项目,可模拟http,https,Socket协议。moco有几种使用方法,这里介绍的是standolone用法,更多用法可参考https://github.com/dreamhead/moco/blob/master/moco-doc/usage.md
Usage
You have several ways to use Moco. One is API, which you can use in your unit test. The other is that run Moco as standalone. Currently, you put all your configuration in JSON file.
On the other hand, Moco has several different ways to integrate with some tools: Maven plugin, Gradle plugin and shell support
二、moco的启动及demo
1、moco的启动
1)、到github上下载moco-runner-0.12.0-standalone.jar 包【这里下载了当前最新版本】
下载地址https://github.com/dreamhead/moco
2)、moco的启动
在命令行中执行如下命令