java - Java 中是否有框架来设置持久层?

标签 java unit-testing persistence dao

我尝试为 Java 网络应用程序的持久层编写单元测试。我使用 JUnit 来测试服务层,我也想将它用于持久层。

因为应用程序是高度可定制的,持久层可以通过配置更改为使用支持 JDBC 的数据库(MySQL、Postgres、Oracle)和嵌入式数据库(sqljet)。是否有一个框架可以帮助我定义一个用于测试和设置数据存储的数据集?我的目标是编写一组测试并将其用于持久层的所有实现。 DbUnit 不是一个选项,因为我有非 JDBC 版本的持久层 (sqljet)。

提前致谢

马库斯

最佳答案

DBUnit 可能会帮助你

DbUnit is a JUnit extension (also usable with Ant) targeted at database-driven projects that, among other things, puts your database into a known state between test runs. This is an excellent way to avoid the myriad of problems that can occur when one test case corrupts the database and causes subsequent tests to fail or exacerbate the damage.

DbUnit has the ability to export and import your database data to and from XML datasets. Since version 2.0, DbUnit can also work with very large datasets when used in streaming mode. DbUnit can also help you to verify that your database data match an expected set of values.

http://www.dbunit.org/

关于java - Java 中是否有框架来设置持久层?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11541312/

相关文章:

java - 启用非安全/健康端点的 Spring Boot 2

angularjs - 如何在 jasmine 规范中使用 $promise.then 模拟 AngularJS $resource

100M+ 键的 Java 缓存设计?

PHP MySQL 连接持久性

java - 内部异常 : java. sql.SQLException:未选择数据库

java - Jenkins 工作状态的详尽列表?

java - 为什么 Ubuntu 环境中的 Mule-ESB 不使用默认的 Java keystore ?

java - 从 SQL 脚本生成带有 JPA 注释的 Java 类

java - 如何为具有 Autowiring 依赖项的类创建模拟 spring bean

c# - 虚拟方法的性能影响