JUnit是个好东东,简单好用。
选中想测试的目标对象类,选择new-->JUNIT-test-case 生成测试类,简单补充,就可以测试了。
public class MpwdProtectionDaoTest {
private static ApplicationContext act=null;
@Before
public void setUp() throws Exception {
String[]files=new String[]{"applicationContext-resource.xml",
"applicationContext-service.xml",
"applicationContext-dao.xml",};
act=new ClassPathXmlApplicationContext(files);
}
//@Test
public void testSaveOrUpdate() {
MpwdProtectionManager mpwdsrv=(MpwdProtectionManager)act.getBean("mpwdProtectionManager");
MpwdProtection mpwd=new MpwdProtection();
mpwd.setCreateTime(new Timestamp(System.currentTimeMillis()));
mpwd.setUserId((long)29);
mpwd.setProtectionEmail("fsh430623@163.com");
mpwdsrv.saveOrUpdate(mpwd);
}
@Test
public void testSave() {
MpwdProtectionManager mpwdsrv=(MpwdProtectionManager)act.getBean("mpwdProtectionManager");
MpwdProtection mpwd=new MpwdProtection();
mpwd.setCreateTime(new Timestamp(System.currentTimeMillis()));
mpwd.setUserId((long)29);
mpwd.setProtectionEmail("fsh430623@163.com");
mpwdsrv.save(mpwd);
}
}
选中想测试的目标对象类,选择new-->JUNIT-test-case 生成测试类,简单补充,就可以测试了。
public class MpwdProtectionDaoTest {
private static ApplicationContext act=null;
@Before
public void setUp() throws Exception {
String[]files=new String[]{"applicationContext-resource.xml",
"applicationContext-service.xml",
"applicationContext-dao.xml",};
act=new ClassPathXmlApplicationContext(files);
}
//@Test
public void testSaveOrUpdate() {
MpwdProtectionManager mpwdsrv=(MpwdProtectionManager)act.getBean("mpwdProtectionManager");
MpwdProtection mpwd=new MpwdProtection();
mpwd.setCreateTime(new Timestamp(System.currentTimeMillis()));
mpwd.setUserId((long)29);
mpwd.setProtectionEmail("fsh430623@163.com");
mpwdsrv.saveOrUpdate(mpwd);
}
@Test
public void testSave() {
MpwdProtectionManager mpwdsrv=(MpwdProtectionManager)act.getBean("mpwdProtectionManager");
MpwdProtection mpwd=new MpwdProtection();
mpwd.setCreateTime(new Timestamp(System.currentTimeMillis()));
mpwd.setUserId((long)29);
mpwd.setProtectionEmail("fsh430623@163.com");
mpwdsrv.save(mpwd);
}
}