SpringClassRule/SpringMethodRule实际上做了什么?

IKo*_*IKo 5 integration-testing rule spring-boot

在集成测试类中,我遇到了以下代码行:

    @ClassRule
    public static final SpringClassRule SPRING_CLASS_RULE = new SpringClassRule();

    @Rule
    public final SpringMethodRule springMethodRule = new SpringMethodRule();
Run Code Online (Sandbox Code Playgroud)

当我尝试导航到课程时(我使用Intellij Idea)我得到'找不到声明去'.当我试图找到用法时,我得到"项目中没有找到用法"我熟悉规则的概念.但仍然不明白这两件事做了什么.我查看了这个页面:https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/ 没有信息.

Dar*_*the 6

这些不是Spring Boot特定的注释,而是来自Spring Framework本身,允许使用Spring Contexts等而不使用SpringRunner.

Javadoc,http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/test/context/junit4/rules/SpringClassRule.html

这里有一个具体的例子,

http://eddumelendez.github.io/blog/2015/08/01/spring-4-2-0-springclassrule-and-springmethodrule/