In Spring ContextConfiguration (...) inherits from parent @ContextConfiguration?

Suppose I have a parent test class:

@ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes = { MyCustomTestConfig.class })
public class MyParentTestclass {

Then I have a child class in which I want to add the Spring 3.2.3 attribute of the name annotation .

@ContextConfiguration(name=MyName)
public class MyChildTestClass extends MyParentTestClass {

I still want to get the entire context configuration from the parent, but I'm not sure if this will happen.

My question is: Does Spring execute ContextConfiguration (...) from the parent @ContextConfiguration?

+4
source share
1 answer

@ContextConfiguration makes inheritance support out of the box.

@ContextConfiguration inheritLocations, true , .

inheritLocations = true. , , . , , . , .

inheritLocations false, , .

, , ApplicationContext ExtendedTest BaseConfig ExtendedConfig . Beans, ExtendedConfig, , BaseConfig.

 @ContextConfiguration(classes=BaseConfig.class)
 public class BaseTest {
     // ...
 }

 @ContextConfiguration(classes=ExtendedConfig.class)
 public class ExtendedTest extends BaseTest {
     // ...
 }
+1

All Articles