Package org.junit.internal.runners.rules
Class RuleMemberValidator
java.lang.Object
org.junit.internal.runners.rules.RuleMemberValidator
A RuleMemberValidator validates the rule fields/methods of a
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static final class
Requires the member's declaring class to be publicprivate static final class
Requires the member is a field implementingMethodRule
orTestRule
private static final class
Requires the member is a field implementingTestRule
private static final class
Requires the validated member to be non-staticprivate static final class
Requires the member to be publicprivate static final class
Requires the member to be staticprivate static final class
Require the member to return an implementation ofMethodRule
orTestRule
private static final class
Require the member to return an implementation ofTestRule
(package private) static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Class
<? extends Annotation> static final RuleMemberValidator
Validates methods with aClassRule
annotation.static final RuleMemberValidator
Validates fields with aClassRule
annotation.private final boolean
static final RuleMemberValidator
Validates methods with aRule
annotation.static final RuleMemberValidator
Validates fields with aRule
annotation.private final List
<RuleMemberValidator.RuleValidator> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static RuleMemberValidator.Builder
private static boolean
isMethodRule
(FrameworkMember<?> member) private static boolean
isRuleType
(FrameworkMember<?> member) private static boolean
isTestRule
(FrameworkMember<?> member) private static RuleMemberValidator.Builder
void
Validate theTestClass
and adds reasons for rejecting the class to a list of errors.private void
validateMember
(FrameworkMember<?> member, List<Throwable> errors)
-
Field Details
-
CLASS_RULE_VALIDATOR
Validates fields with aClassRule
annotation. -
RULE_VALIDATOR
Validates fields with aRule
annotation. -
CLASS_RULE_METHOD_VALIDATOR
Validates methods with aClassRule
annotation. -
RULE_METHOD_VALIDATOR
Validates methods with aRule
annotation. -
annotation
-
methods
private final boolean methods -
validatorStrategies
-
-
Constructor Details
-
RuleMemberValidator
RuleMemberValidator(RuleMemberValidator.Builder builder)
-
-
Method Details
-
validate
Validate theTestClass
and adds reasons for rejecting the class to a list of errors.- Parameters:
target
- theTestClass
to validate.errors
- the list of errors.
-
validateMember
-
classRuleValidatorBuilder
-
testRuleValidatorBuilder
-
isRuleType
-
isTestRule
-
isMethodRule
-