JUnit真好用

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("[email protected]");
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("[email protected]");
mpwdsrv.save(mpwd);
}



}

猜你喜欢

转载自fsh430623.iteye.com/blog/1869752