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,一个测试的例子就好了。
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/