我的wiremock似乎不能与autoconfigure一起工作。我在类路径中名为stubs的文件夹中有json文件,我在端口8080上运行了独立jar。
@AutoConfigureWireMock(stubs="classpath:/stubs", port = 0)
public class TestResource {
@Autowired
private Service service;
@Test
public void contextLoads() throws Exception {
assertThat(this.service.go()).isEqualTo("Hello World!");
}
}
json文件示例
{
"request" : {
"url" : "/api/users",
"method" : "GET",
"bodyPatterns" : [ {
"contains" : "some soap body"
}]
},
"response" : {
"status" : 200,
"body" : "Hello World",
"headers" : {
"X-Application-Context" : "application:-1",
"Content-Type" : "text/plain"
}
}
}
当我使用get->启动请求时localhost:8080/api/users/ 它与json文件不匹配。
提前谢谢
1条答案
按热度按时间wb1gzix01#
我只是简单地添加了所有的json和一个post请求localhost:8080/__admin/mappings/import http://wiremock.org/docs/stubbing/