直接开始正题!
1.java JDK安装(不需要多说)
验证JDK安装成功
2.下载下载moco-runner jar文件
下载地址:https://repo1.maven.org/maven2/com/github/dreamhead/moco-runner/0.11.0/moco-runner-0.11.0-standalone.jar
3.编写配置文件:新建一个json的文件内容如下(PS:配置问价和moco-runner.jar一定要放到同一个文件夹中)
4.执行命令,打开cmd,通过配置文件 test.json 启动 moco服务在命令行输入:
cmd进入放置jar包和json文件的文件夹目录
java -jar moco-runner-<version>-standalone.jar http -p 12306 -c test.json (ps:< version> 替换为下载的 Jar 包的版本,此处为 0.11.0 )
所以正确的命令为:java -jar moco-runner-0.11.0-standalone.jar http -p 12306 -c test.json
5.访问url
浏览器访问:http://localhost:12306
直接可以看到配置文件中返回的内容啦
好勒,moco初步的测试服务器搭建就是这样,后面还会更新一些字段的使用,让我们进阶,更好的模拟测试