Description
Dave Syer opened SPR-7754 and commented
Now that @Profile
(and "profile" generally) has a meaning in the framework, the old test support for detecting system properties looks like it has an awkward name. In Spring 3.1 terms, what @IfProfileValue
does is detect key-value pairs in the Environment (not profiles).
One simple thing we should definitely do is add a ProfileValueSource that can pull values from the Environment.
More radically, maybe we could rename @IfProfileValue
(name=,value=) to @Environment
(key=,value=).
Another suggestion is that we could provide a way to activate profiles declaratively for tests or test classes. Something I've been playing with is this (new components ProfileSuite and @ActiveProfile
):
@RunWith(Suite.class)
@SuiteClasses({ HsqlTest.class, DerbyTest.class })
public class JdbcDaoIntegrationTests {
@RunWith(ProfileSuite.class)
@SuiteClasses({ JdbcSearchableJobInstanceDaoTests.class, JdbcSearchableJobExecutionDaoTests.class,
JdbcSearchableStepExecutionDaoTests.class })
public static abstract class BaseTest {
}
@ActiveProfile("hsql")
public static class HsqlTest extends BaseTest {
}
@ActiveProfile("derby")
public static class DerbyTest extends BaseTest {
}
}
It says: run these three test classes twice each, once with profile "hsql" and once with profile "derby". This has the nice feature that @EnvironmentValue
can still be honoured inside the individual tests (per method).
Issue Links:
SystemProfileValueSource
is not very compatible with the new 3.1 default system property profiles [SPR-8985] #13625 SystemProfileValueSource is not very compatible with the new 3.1 default system property profiles- TestContext framework should support declarative configuration of bean definition profiles [SPR-7960] #12615 TestContext framework should support declarative configuration of bean definition profiles
- Allow overriding
@ActiveProfiles
in test classes with system property [SPR-8982] #13622 Allow overriding@ActiveProfiles
in test classes with system property - Introduce annotation to disable test based on active Spring profile [SPR-11677] #16300 Introduce annotation to skip test based on active Spring profile
6 votes, 7 watchers