Skip to content

Introduce strategy for determining if a profile value is enabled for a particular test environment [SPR-4862] #9538

Closed

Description

@spring-projects-issues

Sam Brannen opened SPR-4862 and commented

ProfileValueSourceConfiguration allows one to configure an implementation for the ProfileValueSource strategy; however, AbstractJUnit38SpringContextTests and SpringJUnit4ClassRunner are currently hard coded to use ProfileValueUtils.isTestEnabledInThisEnvironment() which only matches on an exact value.

It would be beneficial to be able to configure different strategies for determining if a profile value is enabled for the current environment. The above classes could then delegate to the configured strategy. For backwards compatibility, the default strategy should simply delegate to ProfileValueUtils.isTestEnabledInThisEnvironment(); whereas, additional, pluggable strategies (e.g., one using regular expressions) could be provided for greater flexibility.

Further input from #10572:

It is a typical situation when one might have to run a combination of tests belonging to different test-groups. For example, a test method A is part of the 'smoke' test group, and test method B belongs to 'integration' test group. If you want to execute test methods A and B, you have to run two separate JUnit runs: one for 'smoke' and a separate one for 'integration'.

It would be great to have a way to combine tests from more than one test group in a single test run, for example:

% ant -Dtest-groups=smoke,integration run-tests 

A strategy which considers the value to be a comma-separated list could provide such support with OR semantics.


Affects: 2.5.4, 2.5.5, 2.5.6

Reference URL: http://forum.springframework.org/showthread.php?p=182516

Issue Links:

5 votes, 3 watchers

Activity

  1. spring-projects-issues commented on Nov 10, 2010

    @spring-projects-issues
    CollaboratorAuthor

    Dave Syer commented

    Note that Junit 4.8.2 has support for @Category based test selection. Maybe we should migrate to use that as a building block.

  2. spring-projects-issues commented on Nov 16, 2010

    @spring-projects-issues
    CollaboratorAuthor

    Dave Syer commented

    org.springframework.core.env.Environment is here now as well, so that is an even better fit (given that @Category is still experimental). Environment has a multi-valued character (you can ask for active profiles plural). But it doesn't have the name=value character that @IfProfileActive has. Maybe we should consider adding that?

  3. added
    in: test
    type: enhancement
    on Jan 11, 2019
  4. self-assigned this
    on Jan 15, 2019
  5. sbrannen commented on Feb 24, 2019

    @sbrannen
    Member

    I am closing this issue due to the age of this issue, the lack of recent community interest, and the fact that Spring provides flexible support for conditional test execution in JUnit Jupiter via @EnabledIf and @DisabledIf.

  6. removed this from the General Backlog milestone on Feb 24, 2019
  7. removed their assignment
    on Jan 19, 2024
  8. added
    status: declined
    on Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: teststatus: declinedtype: enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions