org.springframework.test.context
Annotation Type ContextConfiguration

ContextConfiguration defines class-level metadata that is
used to determine how to load and configure an
ApplicationContext
for test classes.

Prior to Spring 3.1, only path-based resource locations were supported.
As of Spring 3.1, context loaders may choose to support
either path-based or class-based resources (but not both). Consequently
@ContextConfiguration can be used to declare either path-based
resource locations (via the locations() or value()
attribute) or configuration classes (via the classes()
attribute).

Note that the above-mentioned default rules only apply for a standard
AbstractContextLoader subclass such as
GenericXmlContextLoader which is the effective default implementation
used at runtime if locations are configured. See the
documentation for loader() for further details regarding default
loaders.

inheritLocations

The default value is true. This means that an annotated
class will inherit the resource locations or configuration
classes defined by annotated superclasses. Specifically, the resource
locations or configuration classes for an annotated class will be
appended to the list of resource locations or configuration classes
defined by annotated superclasses. Thus, subclasses have the option of
extending the list of resource locations or configuration
classes.

If inheritLocations is set to false, the
resource locations or configuration classes for the annotated class
will shadow and effectively replace any resource locations
or configuration classes defined by superclasses.

In the following example that uses path-based resource locations, the
ApplicationContext
for ExtendedTest will be loaded from
"base-context.xml" and
"extended-context.xml", in that order. Beans defined in
"extended-context.xml" may therefore override those defined in
"base-context.xml".

Similarly, in the following example that uses configuration
classes, the
ApplicationContext
for ExtendedTest will be loaded from the
BaseConfigandExtendedConfig
configuration classes, in that order. Beans defined in
ExtendedConfig may therefore override those defined in
BaseConfig.

loader

If not specified, the loader will be inherited from the first superclass
that is annotated with @ContextConfiguration and specifies an
explicit loader. If no class in the hierarchy specifies an explicit
loader, a default loader will be used instead.