Spring 框架用Junit 测试类

tech2022-08-18  165

创建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(){ 写测试代码 } }

 

最新回复(0)