Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EasyMock API order between static mock and non-static mock #342

Open
johanhaleby opened this issue Jul 24, 2015 · 0 comments
Open

EasyMock API order between static mock and non-static mock #342

johanhaleby opened this issue Jul 24, 2015 · 0 comments

Comments

@johanhaleby
Copy link
Collaborator

From johan.ha...@gmail.com on April 11, 2011 12:25:56

@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: http://code.google.com/p/powermock/issues/detail?id=322

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants