在JUnit 4.10中,BlockJUnit4ClassRunner(SpringJUnit4ClassRunner的超类)看起来像在任何@Before方法之前运行规则一样来构造Statement链.从JUnit 4.10:
protected Statement methodBlock(FrameworkMethod method) {
// ...
Statement statement= methodInvoker(method,test);
statement= possiblyExpectingExceptions(method,test,statement);
statement= withPotentialTimeout(method,statement);
statement= withBefores(method,statement);
statement= withAfters(method,statement);
statement= withRules(method,statement);
return statement;
}
JUnit 4.7似乎以不同的顺序将Statement链拼接起来:
Statement statement= methodInvoker(method,test);
statement= possiblyExpectingExceptions(method,statement);
statement= withPotentialTimeout(method,statement);
statement= withRules(method,statement);
statement= withBefores(method,statement);
statement= withAfters(method,statement);
return statement;
spring-test-3.0.5的父POM似乎表明它取决于JUnit 4.7.我不知道是否使用更新的JUnit会有帮助?