@Documented @Inherited @Retention(value=RUNTIME) @Target(value={TYPE,METHOD}) public @interface IfProfileValue
Test annotation to indicate that a test is enabled for a specific testing
profile or environment. If the configured ProfileValueSource
returns
a matching value()
for the provided name()
, the test will be
enabled.
Note: @IfProfileValue
can be applied at the class level, the method
level, or both. @IfProfileValue
at the class level overrides
method-level usage of @IfProfileValue
for any methods within that
class.
When using SystemProfileValueSource
as the ProfileValueSource
implementation, you can configure a test method to run only on Java VMs from
Sun Microsystems as follows:
@IfProfileValue(name = "java.vendor", value = "Sun Microsystems Inc.") public void testSomething() { // ... }
You can alternatively configure @IfProfileValue
with OR
semantics for multiple values
as follows (assuming a
ProfileValueSource
has been appropriately configured for the
"test-groups" name):
@IfProfileValue(name = "test-groups", values = { "unit-tests", "integration-tests" }) public void testWhichRunsForUnitOrIntegrationTestGroups() { // ... }
As of Spring Framework 4.0, this annotation may be used as a meta-annotation to create custom composed annotations.
ProfileValueSource
,
ProfileValueSourceConfiguration
,
ProfileValueUtils
,
AbstractJUnit4SpringContextTests
,
SpringJUnit4ClassRunner
public abstract String name
name
of the profile value against which to
test.