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對象?