public class WireMockRestDocs extends Object
@RunWith(SpringRunner.class) @SpringBootTest @AutoConfigureRestDocs(outputDir = "target/snippets") @AutoConfigureMockMvc public class WiremockServerRestDocsApplicationTests { @Autowired private MockMvc mockMvc; @Test public void contextLoads() throws Exception { mockMvc.perform(get("/resource")) .andExpect(content().string("Hello World")) .andDo(verify().stub("resource")); }which creates a file "target/snippets/stubs/resource.json" matching any GET request to "/resource". To match POST and PUT, you can also specify the content type using
verify().contentType(...)
and JSON content of the body using
verify().jsonPath(...)
.Constructor and Description |
---|
WireMockRestDocs() |
public static ContractResultHandler verify()
Copyright © 2016–2018 Spring. All rights reserved.