Web Test Client

WebTestClient

  • WebTestClient @Since 5.0
  • WebFlux 设计

bindToController

final WebTestClient testClient = WebTestClient.bindToController(new HelloController()).build();

testClient.get()
  .uri("/demo/hello/say/{world}?p1=P", "W")
  .exchange()
  .expectStatus().isOk()
  .expectBody().jsonPath("$.p1").value(Matchers.equalTo("P"));

Read More