@RunWith(PowerMockRunner.class)
@PrepareForTest({RepositoryCompte.class})
public class ClientTest {
/** Class under test */
private Client client;
private BankAccount mock;
private String numAccount = "0002333899";
@Before
public void setUp() throws Exception {
PowerMock.mockStaticStrict(RepositoryAccount.class);
mock = PowerMock.createStrictMock(BankAccount .class);
client = new Client(mock);
}
@Test
public void testCreateNewAccount() throws
AccountNotAvailableException {
EasyMock.expect(RepositoryAccount.isAvailable(numAccount)).andReturn(true);
mock.addNewAccount(numAccount);
PowerMock.replay(RepositoryAccount.class, mock);
client.createNewAccount(numAccount);
PowerMock.verify(RepositoryAccount.class, mock);
}
}
and my method I need to test the behavior :
public void createNewAccount(String numAccount)
throws AccountNotAvailableException {
if (!RepositoryAccount.isAvailable(numAccount)) { // inst 1
throw new AccountNotAvailableException();
}
bankAccount.addNewAccount(numAccount); // inst 2
}
I would like that RepositoryAccount.isAvailable(numAccount) be
strictly called before bankAccount.addNewAccount(numAccount);
Original issue reported on code.google.com by johan.ha...@gmail.com on 11 Apr 2011 at 10:25
Original issue reported on code.google.com by
johan.ha...@gmail.com
on 11 Apr 2011 at 10:25