You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@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);
From johan.ha...@gmail.com on April 11, 2011 12:25:56
@RunWith(PowerMockRunner.class)
@PrepareForTest({RepositoryCompte.class})
public class ClientTest {
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 :
I would like that RepositoryAccount.isAvailable(numAccount) be
strictly called before bankAccount.addNewAccount(numAccount);
Original issue: http://code.google.com/p/powermock/issues/detail?id=322
The text was updated successfully, but these errors were encountered: