数据访问层测试框架

发布于 2024-08-12 16:32:59 字数 35 浏览 4 评论 0原文

数据访问层有测试框架吗?我正在使用 mysql 数据库。

Is there any testing framework for Data access tier? I'm using mysql DB.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱殇璃 2024-08-19 16:32:59

如果您使用 ORM(例如 Hibernate),那么 DAL 的测试很容易。您所要做的就是指定涉及内存 SQLite 数据库的测试配置,然后针对 SQLite 执行所有 DAL 测试。当然,您首先需要进行适当的数据填充和模式定义。

Dbunit在这里为您提供帮助

If you are using ORM ( such as Hibernate), then the testing for DAL is easy. All you have to do, is to specify a test config involving in memory sqlite database and then executing all your DAL tests against the sqlite. Of course you need to do a proper data population, schema definition in the first place.

Dbunit will help you here.

岁月如刀 2024-08-19 16:32:59

为什么需要数据库测试工具?

使用您的服务(或 DAO)填充数据库。否则,您将重复测试中的固定装置状态以及固定装置中的域逻辑。这将导致更差的可维护性(最明显的是可读性)。

如果您厌倦了发明测试数据,请考虑像 Quickcheck 这样的工具(有适用于所有主要语言)。

Why do you need a database test tool?

Use your services (or DAOs) to populate the database. Otherwise you're going to duplicate your fixture state in your tests and your domain logic in your fixtures. This will result in worse maintainability (most notably readability).

If you get weary of inventing test data think about tools like Quickcheck (there are ports for all major languages).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文