Skip to content

TestContext/ContextConfiguration: inherit loader, not just locations. [SPR-5916] #10585

Closed
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions