diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/ActiveProfiles.java b/org.springframework.test/src/main/java/org/springframework/test/context/ActiveProfiles.java index 207ba69fee8..9b72b5443c6 100644 --- a/org.springframework.test/src/main/java/org/springframework/test/context/ActiveProfiles.java +++ b/org.springframework.test/src/main/java/org/springframework/test/context/ActiveProfiles.java @@ -32,6 +32,7 @@ import java.lang.annotation.Target; * @author Sam Brannen * @since 3.1 * @see SmartContextLoader + * @see MergedContextConfiguration * @see ContextConfiguration * @see org.springframework.context.ApplicationContext * @see org.springframework.context.annotation.Profile @@ -52,7 +53,7 @@ public @interface ActiveProfiles { String[] value() default {}; /** - * The list of bean definition profiles to activate. + * The bean definition profiles to activate. * *

This attribute may not be used in conjunction * with {@link #value}, but it may be used instead of @@ -61,7 +62,46 @@ public @interface ActiveProfiles { String[] profiles() default {}; /** - * TODO Document inheritProfiles. + * Whether or not bean definition profiles from superclasses should be + * inherited. + * + *

The default value is true, which means that an annotated + * class will inherit bean definition profiles defined by an + * annotated superclass. Specifically, the bean definition profiles for an + * annotated class will be appended to the list of bean definition profiles + * defined by an annotated superclass. Thus, subclasses have the option of + * extending the list of bean definition profiles. + * + *

If inheritProfiles is set to false, the bean + * definition profiles for the annotated class will shadow and + * effectively replace any bean definition profiles defined by a superclass. + * + *

In the following examples, the {@code ApplicationContext} for + * {@code BaseTest} will be loaded using only the "base" + * bean definition profile; beans defined in the "extended" profile + * will therefore not be loaded. In contrast, the {@code ApplicationContext} + * for {@code ExtendedTest} will be loaded using the "base" + * and "extended" bean definition profiles. + *

+	 * @ActiveProfiles("base")
+	 * @ContextConfiguration
+	 * public class BaseTest {
+	 *     // ...
+	 * }
+	 * 
+	 * @ActiveProfiles("extended")
+	 * @ContextConfiguration
+	 * public class ExtendedTest extends BaseTest {
+	 *     // ...
+	 * }
+	 * 
+ * + *

Note: {@code @ActiveProfiles} can be used when loading an + * {@code ApplicationContext} from path-based resource locations or + * configuration classes. + * @see ContextConfiguration#locations + * @see ContextConfiguration#classes + * @see ContextConfiguration#inheritLocations */ boolean inheritProfiles() default true;