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 ...

Get Mockito for Spring now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.