java类org.springframework.test.context.junit4.rules.SpringMethodRule的实例源码

SpringJUnit4ClassRunner.java 文件源码 项目:spring4-understanding 阅读 34 收藏 0 点赞 0 评论 0
private static void ensureSpringRulesAreNotPresent(Class<?> testClass) {
    for (Field field : testClass.getFields()) {
        if (SpringClassRule.class.isAssignableFrom(field.getType())) {
            throw new IllegalStateException(String.format("Detected SpringClassRule field in test class [%s], " +
                    "but SpringClassRule cannot be used with the SpringJUnit4ClassRunner.", testClass.getName()));
        }
        if (SpringMethodRule.class.isAssignableFrom(field.getType())) {
            throw new IllegalStateException(String.format("Detected SpringMethodRule field in test class [%s], " +
                    "but SpringMethodRule cannot be used with the SpringJUnit4ClassRunner.", testClass.getName()));
        }
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号