SpringJUnit4ClassRunner 和 SpringRunner 的区别是什么

每当我看到一篇关于 Spring 测试的博客文章时,我都会看到这两个类中的任何一个,但是我不明白它们之间的真正区别:

@RunWith(SpringRunner.class)
@RunWith(SpringJUnit4ClassRunner.class)
32088 次浏览

@RunWith(SpringRunner.class) tells JUnit to run using Spring’s testing support. SpringRunner is the new name for SpringJUnit4ClassRunner, it’s just a bit easier on the eye.

SpringRunner is only available on spring-test 4.3.

SpringRunner class extends SpringJUnit4ClassRunner.

Source code of SpringRunner is

package org.springframework.test.context.junit4;


import org.junit.runners.model.InitializationError;


public final class SpringRunner extends SpringJUnit4ClassRunner {


public SpringRunner(Class<?> clazz) throws InitializationError {
super(clazz);
}


}