DBunit测试(实例)
import java.io.FileInputStream; import junit.framework.TestCase; import org.dbunit.DatabaseTestCase; import? .......dao.AddressDAO; public class TestAddressDao extends DatabaseTestCase { ?/** ?/** ?/**? * 控制测试后的数据库状态? */?@Override?protected DatabaSEOperation getTearDownOperation() throws Exception {//??DatabaSEOperation.DELETE;//??DatabaSEOperation.DELETE_ALL;//??DatabaSEOperation.INSERT;//??DatabaSEOperation.REFRESH;//??DatabaSEOperation.TRUNCATE_TABLE;//??DatabaSEOperation.UPDATE;//??DatabaSEOperation.NONE;??return DatabaSEOperation.DELETE;?}??public void testAddressDAO(){????try {???Address address=addDao.findById(3);???TestCase.assertNotNull("河南",address.getAddName());??} catch (Exception e) {???System.out.println("测试出错!");???e.printStackTrace();??}?}??public void testDelectAllAddress(){??try {//???int delectAllAddress = addDao.DelectAllAddress();//???TestCase.assertEquals(2,delectAllAddress);??} catch (Exception e) {???System.out.println("测试出错!");???e.printStackTrace();??}?}} (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |