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:
- #12615 TestContext framework should support declarative configuration of bean definition profiles
- #13622 Allow overriding @ActiveProfiles
in test classes with system property
- #16300 Introduce annotation to skip test based on active Spring profile
- #8334 Create annotation to group tests
- #10572 Allow multiple values be specified in the runtime for tests filtering by @IfProfileValue
- #10572 Allow multiple values be specified in the runtime for tests filtering by @IfProfileValue
("supersedes")
5 votes, 3 watchers
Comment From: spring-projects-issues
Sam Brannen commented
See related forum thread: http://forum.springframework.org/showthread.php?p=182516
Comment From: spring-projects-issues
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.
Comment From: spring-projects-issues
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?
Comment From: sbrannen
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
.