use of org.junit.Rule in project spring-framework by spring-projects.
the class SpringClassRule method validateSpringMethodRuleConfiguration.
/**
* Throw an {@link IllegalStateException} if the supplied {@code testClass}
* does not declare a {@code public SpringMethodRule} field that is
* annotated with {@code @Rule}.
*/
private static void validateSpringMethodRuleConfiguration(Class<?> testClass) {
Field ruleField = findSpringMethodRuleField(testClass).orElseThrow(() -> new IllegalStateException(String.format("Failed to find 'public SpringMethodRule' field in test class [%s]. " + "Consult the javadoc for SpringClassRule for details.", testClass.getName())));
Assert.state(ruleField.isAnnotationPresent(Rule.class), () -> String.format("SpringMethodRule field [%s] must be annotated with JUnit's @Rule annotation. " + "Consult the javadoc for SpringClassRule for details.", ruleField));
}