How it works...

Spring MVC testing is a method of integration testing provided by the Spring TestContext framework. The framework starts with calling the JUnit 4 runner org.junit.runner.RunWith, which is an annotation used for executing the JUnit 4 tests. The org.springframework.test.context.junit4.SpringJUnit4ClassRunner annotation of the framework is applied to the test class in order to load the ApplicationContext container to the test suite. Let us not forget that all beans involved in testing are @Autowired to the ApplicationContext container.

Aside from the runner, the framework has other annotations namely @WebAppConfiguration and @ContextConfiguration which help load and expose the WebAplicationContext beans to the framework's MockMvc, the provider of all the test utilities for integration testing. One of the useful methods of MockMvc is perform(), which executes a request URI to return a failure or success.

No matter how complete and correct the Spring TestContext configuration is, if the loaded WebApplicationContext beans contains autowiring errors, the whole framework will not work.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.107.85