在SSH中,用哪一个框架来测试DAO组件,如何测试?
正在学习中......

解决方案 »

  1.   

    我说的是在单元测试中,用什么来测试DAO组件?
    不太了解junit,但我在用ssh做一个网站,我必须保证自己写的有一定的正确性
    就是想快速的DAO组件测试.
    有没有知道的?
      

  2.   

    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下)