Class WireMockRestDocs


  • public final class WireMockRestDocs
    extends Object
    Convenience class for setting up RestDocs to record WireMock stubs. Example usage:
     @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())
                                    .andDo(document("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(...).
    Author:
    Dave Syer