在集成测试类中,我遇到了这些代码行:
@ClassRule
public static final SpringClassRule SPRING_CLASS_RULE = new SpringClassRule();
@Rule
public final SpringMethodRule springMethodRule = new SpringMethodRule();
当我尝试导航到该类(我使用 Intellij Idea)时,我收到“找不到要访问的声明”。当我尝试查找用法时,我收到“项目中未找到用法” 我熟悉规则的概念。但还是不明白这两个东西是做什么用的。 我检查了此页面:https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/ 那里没有信息。
请您参考如下方法:
这些不是 Spring Boot 特定的注释,而是来自 Spring 框架本身,并且允许使用 Spring Context 等,而无需使用 SpringRunner
。
具体的例子可以在这里找到,
http://eddumelendez.github.io/blog/2015/08/01/spring-4-2-0-springclassrule-and-springmethodrule/