WireMock伪造服务

可参考:基于Wiremock创建Mock Service平台

1.下载jar包

2.运行WireMock server,模拟出来一个测试服务器

3.编写程序模拟测试结果,如下当访问/book时,则返回一个json对象.

import static com.github.tomakehurst.wiremock.client.WireMock.*;

public class MockServer {

    public static void main(String[] args) {

        configureFor("127.0.0.1", 9999);

        stubFor(get(urlEqualTo("/book"))
                .willReturn(okJson("{'name':'tom'}")));


    }

}

Last updated