package com.ziwen.common; import org.springframework.context.ApplicationContext; import org.unitils.UnitilsJUnit4; import org.unitils.spring.annotation.SpringApplicationContext; public class CommonTest extends UnitilsJUnit4{ @SpringApplicationContext({ "springConfig/applicationContext.xml", "springConfig/bizContext.xml", "springConfig/daoContext.xml"}) private ApplicationContext applicationContext; public ApplicationContext getApplicationContext() { return applicationContext; } public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } } 子类: package com.ziwen.biz; import static org.junit.Assert.assertNotNull; public class TestDemoBiz extends CommonTest{ @SpringBean("demoBiz") private DemoBiz demobiz; @Test public void testDoSth() { List<Demo> list=demobiz.getDemoList(new Page(10)); assertTrue(list.size()>1); } @Test public void testGetDemoList() { String str=demobiz.doSth(); assertNotNull(str); } } |