Closed as not planned
Closed as not planned
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
value
orprofiles
attribute of@ActiveProfiles
- since Spring Framework 3.1 - Specifying a custom
ActiveProfilesResolver
(which programmatically determines the active profiles) declared via theresolver
attribute 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
@ActiveProfiles
specified in an integration test via thespring.profiles.active
system property or some other system property specific to the TCF. - Set the
spring.profiles.active
system 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
boolean
flag in@ActiveProfiles
that allows profiles declared via the annotation to be overridden by those defined via thespring.profiles.active
system 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
SystemProfileValueSource
is 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