Document that spring.profiles.active is ignored by @ActiveProfiles#36600
Conversation
The Test Context Framework does not honor the spring.profiles.active system property when determining active profiles for a test class. This commit documents that behavior in the @activeprofiles and DefaultActiveProfilesResolver Javadoc, as well as in the reference manual. A SystemPropertyActiveProfilesResolver example is also added showing how to allow spring.profiles.active to override @activeprofiles. Closes spring-projectsgh-36269 Signed-off-by: Mohak Nagaraju <98132980+Mohak-Nagaraju@users.noreply.github.com>
sbrannen
left a comment
There was a problem hiding this comment.
Thanks for the PR and for basing it on 7.0.x.
I've requested a few minor changes.
| xref:testing/testcontext-framework/ctx-management/env-profiles.adoc#testcontext-ctx-management-env-profiles-ActiveProfilesResolver[`ActiveProfilesResolver`] | ||
| and registering it by using the `resolver` attribute of `@ActiveProfiles`. | ||
|
|
||
| NOTE: The `spring.profiles.active` system property is not taken into account by the |
There was a problem hiding this comment.
It actually is taken into account if you don't declare @ActiveProfiles -- right?
| xref:testing/testcontext-framework/ctx-management/env-profiles.adoc#testcontext-ctx-management-env-profiles-ActiveProfilesResolver[`ActiveProfilesResolver`] | ||
| and registering it by using the `resolver` attribute of `@ActiveProfiles`. | ||
|
|
||
| NOTE: The `spring.profiles.active` system property is not taken into account by the |
There was a problem hiding this comment.
Although it is usually set as a JVM system property, it's also supported as an environment variable. So, we should revise the wording here.
...ework-docs/modules/ROOT/pages/testing/testcontext-framework/ctx-management/env-profiles.adoc
Show resolved
Hide resolved
| + | ||
| [source,java,indent=0,subs="verbatim,quotes",role="primary"] | ||
| ---- | ||
| public class SystemPropertyActiveProfilesResolver implements ActiveProfilesResolver { |
There was a problem hiding this comment.
Naming is hard. 😉
Perhaps SpringPropertyOverrideActiveProfilesResolver?
Got any better ideas?
| * <p>This annotation will be inherited from an enclosing test class by default. | ||
| * See {@link NestedTestConfiguration @NestedTestConfiguration} for details. | ||
| * | ||
| * <p>Note that the {@code spring.profiles.active} system property is not taken |
There was a problem hiding this comment.
Same as my first comment.
It actually is taken into account if you don't declare
@ActiveProfiles-- right?
spring.profiles.active is ignored by TCFspring.profiles.active is ignored by @ActiveProfiles
In line with comments I left in the review, I've modified the title of this PR to reflect that it's the default behavior of |
Overview
The Test Context Framework does not honor the
spring.profiles.activesystem property when determining active profiles for a test class.This commit documents that behavior in the following places:
@ActiveProfilesJavadocDefaultActiveProfilesResolverJavadoc@ActiveProfilesannotation sectionProfiles section, including a new
SystemPropertyActiveProfilesResolverexample showing howto allow
spring.profiles.activeto override@ActiveProfilesRelated Issues
@ActiveProfilesvia-Dspring.profiles.active#36269spring.profiles.activeis ignored by the TCF #36594