Closed
Description
Sam Brannen opened SPR-12051 and commented
Status Quo
#14865 and #16004 proposed support for using @PropertySource
on test classes and introducing @TestPropertyValue
for declarative PropertySource
value declarations, respectively. This issue supersedes those two issues by combining the two proposals into a dedicated @TestPropertySource
annotation.
Deliverables
- Introduce a new
@TestPropertySource
annotation for configuring a test-specificPropertySource
. -
@TestPropertySource
must support attributes analogous to those found in@PropertySource
(i.e., for declaring resource locations). -
@TestPropertySource
must support an additional attribute that allows for key/value pairs to be declared inline.- See the proposal in Support declarative PropertySource annotations in the TestContext framework [SPR-11377] #16004 as well as the
value
attribute in@IntegrationTest
from Spring Boot for implementation ideas.
- See the proposal in Support declarative PropertySource annotations in the TestContext framework [SPR-11377] #16004 as well as the
- As with
@ActiveProfiles
,@TestPropertySource
declarations on test classes should be inherited by default but overridable via a boolean flag (i.e., attribute in the annotation). - The context cache key (i.e.,
MergedContextConfiguration
) must take test property sources into account.
Further Resources
- See the proposals, analysis, and discussions in Allow @PropertySource to be specified on a test class [SPR-10232] #14865 and Support declarative PropertySource annotations in the TestContext framework [SPR-11377] #16004 for further insight.
ConfigurationClassParser.processPropertySource(AnnotationAttributes)
Issue Links:
- Document @TestPropertySource support in the reference manual [SPR-12076] #16692 Document
@TestPropertySource
support in the reference manual ("is depended on by") - Allow @PropertySource to be specified on a test class [SPR-10232] #14865 Allow
@PropertySource
to be specified on a test class ("supersedes") - Support declarative PropertySource annotations in the TestContext framework [SPR-11377] #16004 Support declarative PropertySource annotations in the TestContext framework ("supersedes")
Referenced from: commits f2ac025, 2cf4147
1 votes, 3 watchers