DAO组件测试 在SSH中,用哪一个框架来测试DAO组件,如何测试?正在学习中...... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我说的是在单元测试中,用什么来测试DAO组件?不太了解junit,但我在用ssh做一个网站,我必须保证自己写的有一定的正确性就是想快速的DAO组件测试.有没有知道的? package com.ht.test;import java.util.List;import junit.framework.TestCase;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;import com.ht.model.SupplyService;import com.ht.pojo.Supply;public class SupplyServiceTest extends TestCase { private ApplicationContext app; private SupplyService supplyService; protected void setUp() throws Exception { app = new ClassPathXmlApplicationContext("applicationContext.xml"); supplyService = (SupplyService) app.getBean("supplyService"); } public void testInsertSupply() { Supply supply = new Supply(); supply.setCeo("zhangsan"); supply.setEmail("[email protected]"); supply.setFax("0631-5651023"); supply.setId(1); supply.setName("教化电子城"); supply.setPhone("1504651873"); this.supplyService.insertSupply(supply); } public void testSelect() { Supply supply = this.supplyService.selectSupplyById(1); System.out.println("by Id" + supply.getName()); List<Supply> list = this.supplyService.selectSupplys(); for (Supply temp : list) System.out.println(temp.getName()); } public void testDeleteSupplys() { System.out.println(this.supplyService.deleteSupplyById(1) == 1 ? "success" : "fail"); System.out.println(this.supplyService.deleteSupplys()); }}supplyService把他换成你的dao就可以了,记的导包,右键=>run as junit(eclipse下) javascript添加行写入数据库的 ssh框架 从数据库查到的是数字,在界面显示时如何转化为汉字或星星 二级联动 无法使用!大家帮我看看啊~ extjs整合jquery或者dojo写Bayeux comet程序? 哪里有免费的空间啊~~~~~100分 菜鸟求助,为啥这么简单的程序不能运行? mybatis spring 用tomcat发布的小问题 请问怎么截取下拉框里的值? 生产环境的数据表维护问题 java,jsp书换c#书或者asp.net书!北京地区 马上要用JAVA开发了,不知道Java是不是很难啊
不太了解junit,但我在用ssh做一个网站,我必须保证自己写的有一定的正确性
就是想快速的DAO组件测试.
有没有知道的?
import org.springframework.context.support.ClassPathXmlApplicationContext;import com.ht.model.SupplyService;
import com.ht.pojo.Supply;public class SupplyServiceTest extends TestCase {
private ApplicationContext app;
private SupplyService supplyService; protected void setUp() throws Exception {
app = new ClassPathXmlApplicationContext("applicationContext.xml");
supplyService = (SupplyService) app.getBean("supplyService");
} public void testInsertSupply() {
Supply supply = new Supply();
supply.setCeo("zhangsan");
supply.setEmail("[email protected]");
supply.setFax("0631-5651023");
supply.setId(1);
supply.setName("教化电子城");
supply.setPhone("1504651873");
this.supplyService.insertSupply(supply);
} public void testSelect() {
Supply supply = this.supplyService.selectSupplyById(1);
System.out.println("by Id" + supply.getName());
List<Supply> list = this.supplyService.selectSupplys();
for (Supply temp : list)
System.out.println(temp.getName());
} public void testDeleteSupplys() {
System.out.println(this.supplyService.deleteSupplyById(1) == 1 ? "success"
: "fail");
System.out.println(this.supplyService.deleteSupplys());
}
}supplyService把他换成你的dao就可以了,记的导包,右键=>run as junit(eclipse下)