Skip to content

Support for dependency injection and initialization of test instances using classpath scanning [SPR-7937] #12592

Closed
@spring-projects-issues

Description

@spring-projects-issues

Magnus Heino opened SPR-7937 and commented

Maybe it's available already? I don't see anything about it though. This seems to work for me...

public class AnnotationConfigApplicationContextLoader implements ContextLoader {

    @Override
    public String[] processLocations(final Class<?> clazz, final String... locations) {
        return locations;
    }

    @Override
    public ApplicationContext loadContext(final String... locations) throws Exception {
        return new AnnotationConfigApplicationContext(locations);
    }

}

and then...

@ContextConfiguration(locations="se.lantmateriet.dominium", loader=AnnotationConfigApplicationContextLoader.class)
public class MyTests { ... }

Issue Links:

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulestatus: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions