gpt4 book ai didi

spring-cloud - 线模错误 : Request was not matched as there were no stubs registered

转载 作者:行者123 更新时间:2023-12-03 23:14:00 27 4
gpt4 key购买 nike

@ClassRule
public static WireMockRule wireMockRule = new WireMockRule(9898);

@Test
public void createXmlFile() {
stubFor(get(urlPathEqualTo("/data/racing/"))
.willReturn(aResponse()
.withBody(loadJSONFile("unibet-demo-input.json"))));

}

我不知道这里出了什么问题!
2019-01-16 15:54:05.810 [qtp1929284175-20] INFO  ROOT:2341 - RequestHandlerClass from context returned com.github.tomakehurst.wiremock.http.StubRequestHandler. Normalized mapped under returned 'null'
2019-01-16 15:54:05.822 [qtp1929284175-15] INFO __admin:2341 - RequestHandlerClass from context returned com.github.tomakehurst.wiremock.http.AdminRequestHandler. Normalized mapped under returned 'null'
2019-01-16 15:54:05.925 [qtp1929284175-20] ERROR WireMock:40 - Request was not matched as there were no stubs registered:
{
"url" : "/data/racing/",
"absoluteUrl" : "http://localhost:9898/data/racing/",
"method" : "GET",
"clientIp" : "127.0.0.1",
"headers" : {
"User-Agent" : "Jakarta Commons-HttpClient/3.1",
"Host" : "localhost:9898",
"batchID" : "1056178410254123336",
"breadcrumbId" : "ID-SBGML01938-1547654042343-0-1"
},
"cookies" : { },
"browserProxyRequest" : false,
"loggedDate" : 1547654045870,
"bodyAsBase64" : "",
"body" : "",
"scheme" : "http",
"host" : "localhost",
"port" : 9898,
"loggedDateString" : "2019-01-16T15:54:05Z",
"queryParams" : { }
}

单击以查看不同之处在于说明内容相同。
com.github.tomakehurst.wiremock.client.VerificationException: A request was unmatched by any stub mapping. Closest stub mapping was:   <Click to see difference>


at com.github.tomakehurst.wiremock.client.VerificationException.forSingleUnmatchedRequest(VerificationException.java:43)
at com.github.tomakehurst.wiremock.client.VerificationException.forUnmatchedNearMisses(VerificationException.java:48)
at com.github.tomakehurst.wiremock.junit.WireMockRule.checkForUnmatchedRequests(WireMockRule.java:92)
at com.github.tomakehurst.wiremock.junit.WireMockRule.access$000(WireMockRule.java:34)
at com.github.tomakehurst.wiremock.junit.WireMockRule$1.evaluate(WireMockRule.java:74)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

最佳答案

我必须在 stubFor 上添加 wireMockRule 才能使其工作。

@ClassRule
public static WireMockRule wireMockRule = new WireMockRule(9898);

@Test
public void createXmlFile() {
wireMockRule.stubFor(get(urlPathEqualTo("/data/racing/"))
.willReturn(aResponse()
.withBody(loadJSONFile("unibet-demo-input.json"))));
}

关于spring-cloud - 线模错误 : Request was not matched as there were no stubs registered,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54220922/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com