所需要的包:
junit需要是4.5以上
org.springframework.test-XXX.RELEASE.jar
package test; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.works.dao.AosBusinessCoolingDao; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"/config/spring/applicationContext.xml"}) public class TestSpringTest extends AbstractJUnit4SpringContextTests { @Autowired private AosBusinessCoolingDao aosBusinessCoolingDao; @Test public void show(){ aosBusinessCoolingDao.findAosBusinessCoolingById(Integer.valueOf(2)); System.out.println("show"); } }
Junit与spring TestContext框架整合
时间: 2024-12-27 08:36:40