You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TestContext supports inheritance of @ContextConfiguration's "locations", but not "loader". This is unfortunate because I use a special ContextLoader to override bean definitions.
Suppose I have 2 test classes:
@ContextConfiguration(loader = FooContextLoader.class, locations = { "Parent.xml" })
public abstract class AbstractParentTest { ... };
@ContextConfiguration // implicitly loads default location.
public class ConcreteChildTest extends AbstractParentTest { ... };
I want ConcreteChildTest to load beans from both Parent.xml and the default location(s), and inherit the ContextLoader from AbstractParentTest.
If I specify a custom loader in AbstractParentTest, it only takes effect if I remove the @ContextConfiguration attribute from ConcreteChildTest.
But if I remove the @ContextConfiguration attribute from ConcreteChildTest, Spring will only load beans from Parent.xml, ignoring the child's default location. =)
ContextLoader class is now inherited from class hierarchy if not specified explicitly via @ContextConfiguration's loader attribute on the current test class.
Marek, if you're still seeing this behavior against the latest version of Spring (3.1.1 or 3.2.0.M1 at time of writing), please log a new issue against the Test component and mention this issue ID when doing so. Thanks!
Jason Novak opened SPR-5916 and commented
TestContext supports inheritance of
@ContextConfiguration
's "locations", but not "loader". This is unfortunate because I use a special ContextLoader to override bean definitions.Suppose I have 2 test classes:
@ContextConfiguration
(loader = FooContextLoader.class, locations = { "Parent.xml" })public abstract class AbstractParentTest { ... };
@ContextConfiguration
// implicitly loads default location.public class ConcreteChildTest extends AbstractParentTest { ... };
I want ConcreteChildTest to load beans from both Parent.xml and the default location(s), and inherit the ContextLoader from AbstractParentTest.
If I specify a custom loader in AbstractParentTest, it only takes effect if I remove the
@ContextConfiguration
attribute from ConcreteChildTest.But if I remove the
@ContextConfiguration
attribute from ConcreteChildTest, Spring will only load beans from Parent.xml, ignoring the child's default location. =)Affects: 2.5.6
Referenced from: commits fc79d98, b2c723a, ba27c29
The text was updated successfully, but these errors were encountered: