public void testRegistOk() throws Exception {
Account employee = new Account(\"name\");
employee.setPassword(\"password\"); accountService.regist(employee); [Page]
control.setVoidCallable(1);
control.replay();
AccountAction action = new AccountAction();
action.setAccount(employee);
action.setAccountService(accountService);
assertEquals(Action.SUCCESS, action.regist());
control.verify();
}
public void testRegistNameExists() throws Exception {
Account employee = new Account(\"name\");
employee.setPassword(\"password\");
accountService.regist(employee);
control.setThrowable(new ObjectExistsException(\"\"));
control.replay();
AccountAction action = new AccountAction();
action.setAccount(employee);
action.setAccountService(accountService);
assertEquals(Action.INPUT, action.regist()); [Page]
control.verify();
}
}
ok,一個測試的例子就好了。
延伸閱讀
文章來源于領測軟件測試網 http://www.kjueaiud.com/