gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 05:57:24 25 4
gpt4 key购买 nike

我尝试为 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com