spring-projects / spring-projects/spring-framework

Support @ContextConfiguration at method level [SPR-12031]

Open
#16,647 32 comments 3 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

Rob Winch opened SPR-12031 and commented

Status Quo

The Spring TestContext Framework (TCF) makes it very easy to run tests that share the same configuration within a test class hierarchy or even across a test suite. However, it does not support annotating a method with @ContextConfiguration.

Proposals
  1. It would be nice if the TCF would allow @ContextConfiguration on a test method. This would allow for easily testing various permutations of configuration.
  2. Support throw-away contexts (i.e., contexts that are loaded for a single test method but not stored in the context cache), perhaps via a separate issue that serves as a building block for this issue.
    • See #18295.

Issue Links:

  • #19600
  • #13977
  • #18951
  • #18295
  • #1255

Referenced from: commits https://github.com/spring-projects/spring-framework-issues/commit/73db0e2ca5fc017caa8914e393d36d039a43b480

7 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

Start by reading the Spring TestContext Framework implementation and the related issues #18295, #19600, #13977, #18951, and #1255 to understand the existing context-cache behavior. Done means the framework supports @ContextConfiguration on test methods with clearly defined handling for method-specific or throw-away contexts, backed by tests for the proposed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.