使用JUnit执行插入 [英] Using JUnit to perform an insert

查看:65
本文介绍了使用JUnit执行插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用JUnit测试将数据插入表中.这可能吗?如果是这样,怎么办?谢谢!

I need to insert data into a table using JUnit tests. Is this possible? If so, how? Thanks!

推荐答案

签出 DBUnit .

DbUnit是一个JUnit扩展(也可与Ant一起使用),用于数据库驱动的项目,除其他事项外,它使您的数据库在两次测试运行之间进入已知状态.这是避免一个测试用例破坏数据库并导致后续测试失败或加剧损坏的无数问题的绝佳方法.

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能够与XML数据集之间导出和导入数据库数据.从2.0版开始,在流式模式下使用DbUnit时,它也可以处理非常大的数据集. DbUnit还可以帮助您验证数据库数据是否与期望的一组值匹配.

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.

这篇关于使用JUnit执行插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆