What is the difference between MockMvc and WebTestClient?

心不动则不痛 提交于 2019-12-01 04:09:13
nobar

Similarities

  • Both provide a fluent-style syntax for testing web services.
  • Both can or do operate in a simulated environment that bypasses the use of HTTP.

Major Differences

  • WebTestClient can also be used to test real web services using HTTP.
    • Specify @SpringBootTest instead of @WebFluxText.
  • WebTestClient only works if you are using Netty for your local server.
    • This feels like an artificial limitation for the test environment.
    • It is likely due to the non-blocking nature of the underlying WebClient.
  • WebTestClient can test Streaming Responses

Resources

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!