0
我想测试http请求/响应。所以我使用WireMock。WireMock:存根 - 如何获取对象“testClient”?
我想存根特定请求响应: 下面的代码:
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对象?