创建BaseJunit4Test类 加上注解
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
public class BaseJunit4Test {
}
创建test类继承BaseJunit4Test类
public class MyTest extends BaseJunit4Test{
@Test
public void testRedis(){
写测试代码
}
}