Skip to content

Clearly document semantics and behavior of SpringExtension.getApplicationContext() #35764

@snicoll

Description

@snicoll

SpringExtension#getApplicationContext is public API available to anyone building integration with a test that uses SpringExtension. There are certain callbacks that happen early and we should not use that method as it will load the context too soon.

I think the Javadoc of this method deserves a warning. First of all, it's not obvious it'll load the context if necessary (vs. the method being merely a way to retrieve the ApplicationContext from the ExtensionContext).

I've been told ParameterResolver#supportParameter is one of those callbacks where we can't use the context. Looking at the Javadoc of ParameterResolver there is a way to figure that out as long as you understand how SpringExtension works and when it should ideally load the context. Linking that information in the Javadoc of SpringApplication#getApplicationContext would be worthwhile as well.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions