-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Closed as not planned
Closed as not planned
Copy link
Labels
has: votes-jiraIssues migrated from JIRA with more than 10 votes at the time of importIssues migrated from JIRA with more than 10 votes at the time of importin: testIssues in the test moduleIssues in the test modulestatus: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement
Description
Alex opened SPR-8982 and commented
Status Quo
Support for setting the active bean definition profiles in an integration test within the Spring TestContext Framework (TCF) is currently limited to one of the following techniques:
- Providing a hard-coded list of profiles declared via the
valueorprofilesattribute of@ActiveProfiles- since Spring Framework 3.1 - Specifying a custom
ActiveProfilesResolver(which programmatically determines the active profiles) declared via theresolverattribute of@ActiveProfiles- since Spring Framework 4.0
In stand-alone or production code, Spring honors the spring.profiles.active system property for determining the set of active profiles to use when loading an ApplicationContext; however, the TCF ignores this system property, relying solely on configuration via @ActiveProfiles.
Proposals
- Provide the ability to override
@ActiveProfilesspecified in an integration test via thespring.profiles.activesystem property or some other system property specific to the TCF. - Set the
spring.profiles.activesystem property to the value specified via@ActiveProfiles- See comments in this issue for background.
- This point likely warrants its own JIRA issue for proper consideration.
Implementation Notes
- Consider introducing a new
booleanflag in@ActiveProfilesthat allows profiles declared via the annotation to be overridden by those defined via thespring.profiles.activesystem property (if it is present).
Further Resources
Related discussions at Stack Overflow:
- Spring integration tests with profile
- Defining a spring active profile within a test use case
- @ActiveProfiles value is not being assigned to config
Affects: 3.1 GA
Issue Links:
- Decide what to do with
@IfProfileValue[SPR-7754] #12410 Decide what to do with@IfProfileValue - Introduce strategy for determining if a profile value is enabled for a particular test environment [SPR-4862] #9538 Introduce strategy for determining if a profile value is enabled for a particular test environment
SystemProfileValueSourceis not very compatible with the new 3.1 default system property profiles [SPR-8985] #13625 SystemProfileValueSource is not very compatible with the new 3.1 default system property profiles- Introduce annotation to disable test based on active Spring profile [SPR-11677] #16300 Introduce annotation to skip test based on active Spring profile
- spring.profiles.active is not honored when building the context cache key in the TestContext framework [SPR-11135] #15761 spring.profiles.active is not honored when building the context cache key in the TestContext framework
19 votes, 24 watchers
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
has: votes-jiraIssues migrated from JIRA with more than 10 votes at the time of importIssues migrated from JIRA with more than 10 votes at the time of importin: testIssues in the test moduleIssues in the test modulestatus: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement