The Spring Framework provides a set of Spring-specific annotations for unit and integration tests in conjunction with the TestContext
framework. The following are widely used annotations:
@ContextConfiguration
: We have already covered this annotation and loadedapplicationContext
for integration tests. This annotation is used to determine how to load and configure anApplicationContext
for integration tests.@ContextConfiguration
declares the application context's resource locations or the annotated classes that will be used to load the context.@WebAppConfiguration
: This class-level annotation is used to instruct the Spring context that theApplicationContext
loaded using the@ContextConfiguration
annotation is aWebApplicationContext
. We will useWebApplicationContext
in the next section.@ContextHierarchy
: This is a class-level annotation that loads the parent-child application context in hierarchical order. The following integration test declares a context hierarchy...