有人能给我指出有关 Spring mvc 测试的良好信息来源吗?我想测试一下:
实体:我希望能够在数据库中创建新记录、获取所有记录并断言新元素计数。
@Controllers:我希望能够模拟 get、post 或 put 到特定路径,并通过模拟 RequestBody 使其到达 @Controller
服务:我希望能够从 JUnit 测试调用 Autowiring 服务并对实体执行操作。
换句话说,我来自 Rails,正在尝试理解 Spring 的测试方式,最好不要模拟任何东西......
最佳答案
您应该阅读 Spring MVC 测试项目:https://github.com/spring-projects/spring-test-mvc
记住它还在阁楼里。
@ChristianMuller 的注释:
- 实体:如果您对 Spring/Hibernate/JUnit 内存解决方案感兴趣,请查看以下内容:http://tshikatshikaaa.blogspot.de/2012/09/junit-testing-spring-service-and-dao .html
关于java - Spring、JUnit、Hibernate 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22341092/