类 ServletTestExecutionListener

java.lang.Object
cn.taketoday.test.context.support.AbstractTestExecutionListener
cn.taketoday.test.context.web.ServletTestExecutionListener
所有已实现的接口:
cn.taketoday.core.Ordered, TestExecutionListener

public class ServletTestExecutionListener extends AbstractTestExecutionListener
TestExecutionListener which provides mock Servlet API support to WebServletApplicationContext loaded by the Infra TestContext Framework.

Specifically, ServletTestExecutionListener sets up thread-local state via Infra Web's RequestContextHolder during test instance preparation and before each test method and creates a MockHttpServletRequest, MockHttpServletResponse, and RequestContext based on the MockServletContext present in the WebApplicationContext. This listener also ensures that the MockHttpServletResponse and ServletWebRequest can be injected into the test instance, and once the test is complete this listener cleans up thread-local state.

Note that ServletTestExecutionListener is enabled by default but generally takes no action if the test class is not annotated with @WebAppConfiguration. See the javadocs for individual methods in this class for details.

从以下版本开始:
4.0
作者:
Sam Brannen, Phillip Webb