类 MockMvcBuilders
MockMvcBuilders.
Eclipse Users
Consider adding this class as a Java editor favorite. To navigate to this setting, open the Preferences and type "favorites".
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Sam Brannen
- 另请参阅:
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static StandaloneMockMvcBuilderstandaloneSetup(Object... controllers) Build aMockMvcinstance by registering one or more@Controllerinstances and configuring Web MVC infrastructure programmatically.static DefaultMockMvcBuilderwebAppContextSetup(cn.taketoday.web.servlet.WebApplicationContext context) Build aMockMvcinstance using the given, fully initialized (i.e., refreshed)WebApplicationContext.
-
构造器详细资料
-
MockMvcBuilders
private MockMvcBuilders()
-
-
方法详细资料
-
webAppContextSetup
public static DefaultMockMvcBuilder webAppContextSetup(cn.taketoday.web.servlet.WebApplicationContext context) Build aMockMvcinstance using the given, fully initialized (i.e., refreshed)WebApplicationContext.The
DispatcherServletwill use the context to discover Web MVC infrastructure and application controllers in it. The context must have been configured with aServletContext. -
standaloneSetup
Build aMockMvcinstance by registering one or more@Controllerinstances and configuring Web MVC infrastructure programmatically.This allows full control over the instantiation and initialization of controllers and their dependencies, similar to plain unit tests while also making it possible to test one controller at a time.
When this builder is used, the minimum infrastructure required by the
DispatcherServletto serve requests with annotated controllers is created automatically and can be customized, resulting in configuration that is equivalent to what MVC Java configuration provides except using builder-style methods.If the Web MVC configuration of an application is relatively straight-forward — for example, when using the MVC namespace in XML or MVC Java config — then using this builder might be a good option for testing a majority of controllers. In such cases, a much smaller number of tests can be used to focus on testing and verifying the actual Web MVC configuration.
- 参数:
controllers- one or more@Controllerinstances to test (specifiedClasswill be turned into instance)
-