spring-projects / spring-projects/spring-framework

Support @TestPropertySource at method level [SPR-14378]

Open
#18,951 24 comments 115 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: test type: enhancement
Dominant language
Java
Stars
60.2k
Forks
38.8k
Avg merge
5d 2h
Merged PRs (30d)
27

Description

Justin Knowles opened SPR-14378 and commented

@TestPropertySource allows you to set test-suite / class-level properties, but I want test-level properties so I can test drive classes with @ConditionalOnProperty and @Value(${var:default}) type annotations for correct behavior.

I have considered creating separate test suites for each test, but that seems unnatural. I currently manually manage the context within the test to validate the behavior.


Issue Links:

  • #13977 Support @ActiveProfiles at method level
  • #16647 Support @ContextConfiguration at method level

8 votes, 14 watchers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named in the issue. Start by locating the existing @TestPropertySource handling and review the related method-level @ActiveProfiles and @ContextConfiguration issues; done means test methods can provide distinct property values for conditional and @Value behavior without manually managing the context.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.