Book Image

Mockito for Spring

By : Sujoy Acharya
Book Image

Mockito for Spring

By: Sujoy Acharya

Overview of this book

Table of Contents (12 chapters)
Mockito for Spring
About the Author
About the Reviewers

Chapter 3. Working with Spring Tests

This chapter covers the test module of Spring and the APIs used for unit and integration testing Spring applications. The following topics are covered here:

  • Spring's TestContext framework and SpringJUnit4ClassRunner

  • Spring profiles

  • Mocking environments with MockEnvironment and MockPropertySource

  • Mocking a JNDI lookup with SimpleNamingContextBuilder and ExpectedLookupTemplate

  • Testing with ReflectionTestUtils

  • Exploring Spring annotations for unit testing; the annotations covered are @ContextConfiguration, ApplicationContextInitializer, @WebAppConfiguration, @ContextHierarchy, @ActiveProfiles, @ProfileValueSourceConfiguration, @TestPropertySource, @DirtiesContext, @TestExecutionListeners, @IfProfileValue, @Timed, and @Repeat

  • Unit testing Spring MVC with MockHttpServletRequest, MockHttpSession, and ModelAndViewAssert, as well as Spring beans with request scope and Spring beans with session scope

  • Mocking a servlet container with MockMvc

  • Transaction management with...