【发布时间】:2014-03-12 02:54:41
【问题描述】:
有人可以指出有关 Spring mvc 测试的良好信息来源吗?我想测试一下:
实体:我希望能够在数据库中创建新记录,获取所有记录并对新元素计数进行断言。
@Controllers:我希望能够模拟 get、post 或 put 到特定路径,并通过模拟 RequestBody 使其到达 @Controller
服务:我希望能够从 JUnit 测试中调用自动装配服务并对实体执行操作。
换句话说,我来自 Rails,并试图了解 Spring 的测试方式,最好不要 Mocking 任何东西......
【问题讨论】:
-
休眠:JUnit。服务:Junit + Mockito 控制器:JUnit + Mockito 所以查找 Junit 和 Mockito。
-
1.实体:如果您对 Spring/Hibernate/JUnit In-Memory 解决方案感兴趣,请查看:http://tshikatshikaaa.blogspot.de/2012/09/junit-testing-spring-service-and-dao.html
-
谢谢@ChristianMüller,也很有用。
标签: java spring hibernate spring-mvc junit