Spring单元测试

拥有回忆 提交于 2020-01-10 00:23:04

第一步,引入依赖:

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

<org.springframework.version>5.0.7.RELEASE</org.springframework.version>

org.springframework spring-core ${org.springframework.version} org.springframework spring-test ${org.springframework.version} test junit junit 4.12 test

第二步:
编写测试类:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(“classpath:applicationContext.xml”) //配置文件地址
public class AopTest {
@Resource(name=“goodsDao”)
private GoodsDao goodsDao;
@Test
public void test(){
goodsDao.save();
}
}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!