public class RuleMemberValidator
extends java.lang.Object
TestClass
. All reasons for rejecting the
TestClass
are written to a list of errors.
There are four slightly different validators. The CLASS_RULE_VALIDATOR
validates fields with a ClassRule
annotation and the
RULE_VALIDATOR
validates fields with a Rule
annotation.
The CLASS_RULE_METHOD_VALIDATOR
validates methods with a ClassRule
annotation and the
RULE_METHOD_VALIDATOR
validates methods with a Rule
annotation.
Modifier and Type | Class and Description |
---|---|
private static class |
RuleMemberValidator.Builder |
private static class |
RuleMemberValidator.DeclaringClassMustBePublic
Requires the member's declaring class to be public
|
private static class |
RuleMemberValidator.FieldMustBeARule
Requires the member is a field implementing
MethodRule or TestRule |
private static class |
RuleMemberValidator.FieldMustBeATestRule
Requires the member is a field implementing
TestRule |
private static class |
RuleMemberValidator.MemberMustBeNonStaticOrAlsoClassRule
Requires the validated member to be non-static
|
private static class |
RuleMemberValidator.MemberMustBePublic
Requires the member to be public
|
private static class |
RuleMemberValidator.MemberMustBeStatic
Requires the member to be static
|
private static class |
RuleMemberValidator.MethodMustBeARule
Require the member to return an implementation of
MethodRule or
TestRule |
private static class |
RuleMemberValidator.MethodMustBeATestRule
Require the member to return an implementation of
TestRule |
(package private) static interface |
RuleMemberValidator.RuleValidator
|
Modifier and Type | Field and Description |
---|---|
private java.lang.Class<? extends java.lang.annotation.Annotation> |
annotation |
static RuleMemberValidator |
CLASS_RULE_METHOD_VALIDATOR
Validates methods with a
ClassRule annotation. |
static RuleMemberValidator |
CLASS_RULE_VALIDATOR
Validates fields with a
ClassRule annotation. |
private boolean |
methods |
static RuleMemberValidator |
RULE_METHOD_VALIDATOR
Validates methods with a
Rule annotation. |
static RuleMemberValidator |
RULE_VALIDATOR
Validates fields with a
Rule annotation. |
private java.util.List<RuleMemberValidator.RuleValidator> |
validatorStrategies |
Constructor and Description |
---|
RuleMemberValidator(RuleMemberValidator.Builder builder) |
Modifier and Type | Method and Description |
---|---|
private static RuleMemberValidator.Builder |
classRuleValidatorBuilder() |
private static boolean |
isMethodRule(FrameworkMember<?> member) |
private static boolean |
isRuleType(FrameworkMember<?> member) |
private static boolean |
isTestRule(FrameworkMember<?> member) |
private static RuleMemberValidator.Builder |
testRuleValidatorBuilder() |
void |
validate(TestClass target,
java.util.List<java.lang.Throwable> errors)
Validate the
TestClass and adds reasons
for rejecting the class to a list of errors. |
private void |
validateMember(FrameworkMember<?> member,
java.util.List<java.lang.Throwable> errors) |
public static final RuleMemberValidator CLASS_RULE_VALIDATOR
ClassRule
annotation.public static final RuleMemberValidator RULE_VALIDATOR
Rule
annotation.public static final RuleMemberValidator CLASS_RULE_METHOD_VALIDATOR
ClassRule
annotation.public static final RuleMemberValidator RULE_METHOD_VALIDATOR
Rule
annotation.private final java.lang.Class<? extends java.lang.annotation.Annotation> annotation
private final boolean methods
private final java.util.List<RuleMemberValidator.RuleValidator> validatorStrategies
RuleMemberValidator(RuleMemberValidator.Builder builder)
public void validate(TestClass target, java.util.List<java.lang.Throwable> errors)
TestClass
and adds reasons
for rejecting the class to a list of errors.target
- the TestClass
to validate.errors
- the list of errors.private void validateMember(FrameworkMember<?> member, java.util.List<java.lang.Throwable> errors)
private static RuleMemberValidator.Builder classRuleValidatorBuilder()
private static RuleMemberValidator.Builder testRuleValidatorBuilder()
private static boolean isRuleType(FrameworkMember<?> member)
private static boolean isTestRule(FrameworkMember<?> member)
private static boolean isMethodRule(FrameworkMember<?> member)