Skip to content

Decide what to do with @IfProfileValue [SPR-7754] #12410

Closed as not planned
Closed as not planned
@spring-projects-issues

Description

@spring-projects-issues

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:

6 votes, 7 watchers

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulestatus: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions