单元测试Junit
2016-10-31 15:33
120 查看
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency><dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> </dependency>
@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:AppContext.xml") @WebAppConfiguration public class Test { @Autowired private BookMarkContentDao bookMarkContentDao; @Autowired private SidChangedDao sidChangedDao; //把主库中修改的sid存入redis中 //@Test public void getBookContentTest() { List<DXHSid> dxhsid = bookMarkContentDao.getCompletedDXHSince(LocalDateTime.now().minusMonths(1), LocalDateTime.now()); List<String> sids = dxhsid.stream().map(x->x.getSid().toString()).collect(Collectors.toList()); for(String sid:sids) sidChangedDao.addSid(sid); } }
对于单元测试不需要完整web工程
对于一个模块中引用其他模块的类时,如要在当前模块的spring配置文件下实例话另一个模块以及另一个模块的相关配置(如数据库连接)
单元测试类的类名不能为Test,即不能和标注@Test相同 ,相同类路径下也不能有test命名的类
相关文章推荐
- 单元测试三叉戟---JUNIT,DBUNIT,UNITILS [ 光影人像 东海陈光剑 的博客 ]
- SpringTest框架JUnit单元测试用例获取ApplicationContext实例的方法
- 应用JUnit实施单元测试
- Hibernate之单元测试利器JUnit
- junit单元测试
- 【学习笔记】系列十五:Ant单元测试JUnit
- 使用junit单元测试的java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing问题解决办法
- 使用Junit进行单元测试时遇到的问题记录[下]
- 使用android-junit-report.jar导出单元测试报告
- JUnit(单元测试)
- spring整合junit单元测试
- spring框架学习(三)junit单元测试
- JUnit单元测试的初步使用
- 在Android上实现Junit单元测试的四部曲
- JUnit自动化单元测试(五):参数化测试
- java中Junit单元测试
- JUnit和单元测试入门简介
- 单元测试常见错误:The import org.junit.Test conflicts with a type defined in the same fil
- spring JPA集成Junit单元测试
- 胡玉洋《三分钟学会JUnit单元测试》