DbUnit
DbUnit
DbUnit is a JUnit extension (also usable with Ant) targeted for 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 works with very large dataset when use in streaming mode. DbUnit can also helps you to verify that your database data match expected set of values.
Homepage: http://dbunit.sourceforge.net/
dbUnit对mssqlserver自增长主键的处理
package com.sourceware.test; /******************************************************************************* * Copyright (c) 2000, 2005 ZhongKe Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 &nbs...
DBUnit与Ant使用
初次使用ant+DbUnit,用ant可以实现,也可以直接写DbUnit的测试代码可现。 dataset.xml 代码: <?xml version='1.0' encoding='UTF-8'?> <dataset> <EMPLOYEE id='1' firstname='Sager' ...
用DBUnit写单元测试
目的搞清楚了就最容易做事了。嘿嘿。如果不知DBUnit是用来做什么的,就像个无头苍蝇,晃了半天都不清楚在看些什么。 DBUnit的主要功能是可以为你的数据库测试提供稳定及一致的数据。DBUnit通过预先在XML文件设置数据值、使用Sql查询另外的表格为测试提供数据等等方式来达到这个目的,而通常我们只需要使用XML文件预置数据的方法即可。 使用DBUnit来写单元测试...
Dbunit最佳实践
原文:http://dbunit.sourceforge.net/bestpractices.html Best Practices Use one database instance per developer Good setup don't need cleanup! Use multiple small datasets Perform setup of stale data once for entire test class or test suite Connection management strategies 每个开发人员使...
dbunit实践指南
什么是dbunit以及为什么要使用它? dbunit是一个基于junit扩展的数据库测试框架。它提供了大量的类对与数据库相关的操作进行了抽象和封装,虽然在80%的情况,你只需使用它极少的api。它通过使用用户自定义的数据集以及相关操作使数据库处于一种可知的状态,从而使得测试自动化、可重复和相对独立。虽然不用dbunit也可以达到这种目的,但是我们...
高效使用dbunit
dbunit: DbUnit is a JUnit extension (also usable with Ant) targeted for database-driven projects official site, 好久没更新了, 最新版本2.1还是2004年5月的 1. use ant task <taskdef classpathref="project.classpath" classname="org.dbunit.ant.DbUnitTask" name="dbunit" /> &...
用DbUnit进行SqlMap单元测试
DbUnit简介 为依赖于其他外部系统(如数据库或其他接口)的代码编写单元测试是一件很困难的工作。在这种情况下,有效的单元必须隔离测试对象和外部依赖,以便管理测试对象的状态和行为。 使用mock object对象,是隔离外部依赖的一个有效方法。如果我们的测试对象是依赖于DAO的代码,mock object技术很方便。但如果测试对象变成了DAO本身,又如何进行单元测试...