【发布时间】:2017-04-26 16:35:07
【问题描述】:
我想测试 http 请求/响应。所以我使用了 WireMock。
我想为特定请求存根响应: 这里代码:
public class WireMockPersons {
@Rule
public WireMockRule wireMockRule = new WireMockRule(8089);
@Test
public void exactUrlOnly() {
stubFor(get(urlEqualTo("/some/thing"))
.willReturn(aResponse()
.withHeader("Content-Type", "text/plain")
.withBody("Hello world!")));
assertThat(testClient.get("/some/thing").statusCode(), is(200));
assertThat(testClient.get("/some/thing/else").statusCode(), is(404));
}
代码无法编译,因为没有对象 testClient。如何获取 testClient 对象?
【问题讨论】:
标签: wiremock