public final class WireMockWebTestClient extends Object
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureRestDocs(outputDir = "target/snippets")
@AutoConfigureWebTestClient
public class WiremockServerRestDocsApplicationTests {
@Autowired
private WebTestClient client;
@Test
public void contextLoads() throws Exception {
client.get().uri("/resource").exchange()
.expectBody(String.class).isEqualTo("Hello World")
.consumeWith(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(...).public static ContractExchangeHandler verify()
Copyright © 2016–2020 Spring. All rights reserved.