我是 WireMock 的新手,并试图让我的第一个单元测试使用它。现在,按照wiremock.org 上的文档,我写了这个
WireMockConfiguration config = wireMockConfig().port(9089).httpsPort(8443);
m_wireMockServer = new WireMockServer(config);
m_wireMockServer.start();
WireMock.configureFor("localhost", 9089);
givenThat(get(urlEqualTo("/some/thing"))
.willReturn(aResponse()
.withHeader("Content-Type", "text/plain")
.withBody("Hello world!")));
我希望这会向 /some/thing 发出任何 http 请求以被捕获。在给定的调用中,它给了我以下异常:
com.github.tomakehurst.wiremock.client.VerificationException: Expected status 201 for http://localhost:9089/__admin/mappings/new but was 200
at com.github.tomakehurst.wiremock.client.HttpAdminClient.postJsonAssertOkAndReturnBody(HttpAdminClient.java:151)
at com.github.tomakehurst.wiremock.client.HttpAdminClient.addStubMapping(HttpAdminClient.java:65)
at com.github.tomakehurst.wiremock.client.WireMock.register(WireMock.java:130)
at com.github.tomakehurst.wiremock.client.WireMock.register(WireMock.java:126)
at com.github.tomakehurst.wiremock.client.WireMock.givenThat(WireMock.java:65)
我错过了什么?创建存根有什么问题?