spring-projects / spring-projects/spring-framework

Introduce annotation to disable test based on active Spring profile [SPR-11677]

Open
#16,300 8 comments 0 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

Torsten Krah opened SPR-11677 and commented

I've looked at the @IfProfileValue and @ActiveProfiles annotations, but neither does what I am searching for.

We are using the "spring.profiles.active" system property to activate different profiles, even at the test level -- e.g. "h2, default" or something else.

We have tests which are only for Oracle and should therefore only be run if the "oracle" profile is active, but I've found no way to express this on the test class itself.

A dedicated annotation would be nice to support this.


Affects: 4.0.3

Issue Links:

  • #12410 Decide what to do with @IfProfileValue
  • #9538 Introduce strategy for determining if a profile value is enabled for a particular test environment
  • #13622 Allow overriding @ActiveProfiles in test classes with system property
  • #13625 SystemProfileValueSource is not very compatible with the new 3.1 default system property profiles

8 votes, 8 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 existing @IfProfileValue and @ActiveProfiles annotations and review the linked issues for prior decisions about profile handling. Define how a test class or method should be enabled by the active Spring profile, then add coverage showing Oracle-only tests run only when the oracle profile is active.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.