This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Framework 6.2.0!spring-doc.cn

AssertJ Integration

The AssertJ integration builds on top of plain MockMvc with several differences:spring-doc.cn

  • There is no need to use static imports as both the requests and assertions can be crafted using a fluent API.spring-doc.cn

  • Unresolved exceptions are handled consistently so that your tests do not need to throw (or catch) Exception.spring-doc.cn

  • By default, the result to assert is complete whether the processing is asynchronous or not. In other words, there is no need for special handling for Async requests.spring-doc.cn

MockMvcTester is the entry point for the AssertJ support. It allows to craft the request and return a result that is AssertJ compatible so that it can be wrapped in a standard assertThat() method.spring-doc.cn