web工程spring+ibatis单元测试
web工程spring+ibatis在本地做单元测试,用例如下:
1 package wanghongye; 2 3 import org.junit.Before; 4 import org.junit.Test; 5 6 import richinfo.dbcomponent.service.impl.SqlMapClientBeanFactory; 7 import richinfo.mms.bean.req.MmsDelRecordReq; 8 import richinfo.mms.dao.MmsRecordDao; 9 import richinfo.tools.common.ConverUtil; 10 11 12 public class Test1 13 { 14 @Before 15 public void beforeTest() 16 { 17 SqlMapClientBeanFactory sqlMapClientBeanFactory = new SqlMapClientBeanFactory(); 18 sqlMapClientBeanFactory 19 .setConfigLocation("classpath:/mms-sql.xml"); 20 } 21 @Test 22 public void testSelect() 23 { 24 //int groupid= 62493;//>1 25 //int groupid= 61606;//fou 26 int groupid= 61894;//1 27 MmsRecordDao dao= new MmsRecordDao(); 28 boolean s = dao.isTimingByGroupId(groupid); 29 System.out.println(">>>>>>>>>>>>>>>>>>"+s); 30 } 31 32 @Test 33 public void testDelete() 34 { 35 String groupid= "62493"; 36 MmsRecordDao dao= new MmsRecordDao(); 37 MmsDelRecordReq req = new MmsDelRecordReq(); 38 req.setGroupIds(groupid); 39 req.setUin(ConverUtil.string2Long("127877")); 40 req.setUserNumber("8615134566830"); 41 boolean s = dao.delSaveRecord(req); 42 System.out.println(">>>>>>>>>>>>>>>>>>"+s); 43 } 44 }
@before是提前类加载本地的配置文件,如local、property,mms-sql.xml。@Test指单独运行单个测试用例