/** * Build a {@link MockMvc} instance by registering one or more * {@code @Controller} instances and configuring Spring MVC infrastructure * programmatically. * <p>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. * <p>When this builder is used, the minimum infrastructure required by the * {@link org.springframework.web.servlet.DispatcherServlet DispatcherServlet} * to 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. * <p>If the Spring 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 Spring MVC configuration. * @param controllers one or more {@code @Controller} instances to test * (specified {@code Class} will be turned into instance) */ public static StandaloneMockMvcBuilder standaloneSetup(Object... controllers) { return new StandaloneMockMvcBuilder(controllers); }
/** * Build a {@link MockMvc} instance by registering one or more * {@code @Controller} instances and configuring Spring MVC infrastructure * programmatically. * <p>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. * <p>When this builder is used, the minimum infrastructure required by the * {@link org.springframework.web.servlet.DispatcherServlet DispatcherServlet} * to 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. * <p>If the Spring 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 Spring MVC configuration. * @param controllers one or more {@code @Controller} instances to test * (specified {@code Class} will be turned into instance) */ public static StandaloneMockMvcBuilder standaloneSetup(Object... controllers) { return new StandaloneMockMvcBuilder(controllers); }
/** * Build a {@link MockMvc} instance by registering one or more * {@code @Controller} instances and configuring Spring MVC infrastructure * programmatically. * <p>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. * <p>When this builder is used, the minimum infrastructure required by the * {@link org.springframework.web.servlet.DispatcherServlet DispatcherServlet} * to 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. * <p>If the Spring 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 Spring MVC configuration. * @param controllers one or more {@code @Controller} instances to test */ public static StandaloneMockMvcBuilder standaloneSetup(Object... controllers) { return new StandaloneMockMvcBuilder(controllers); }