Take the 2-minute tour ×  I'm relatively new to the world of
PowerMock / EasyMock, and something I thought should be
relatively straight-forward just isn't working. Perhaps someone
can show me where I'm going wrong.  Consider these two classes:
public class Foo     public int doStuff(int a)         return (5
/ a);  public class Bar     public void doSomething()
Foo foo = new Foo();         int c = foo.doStuff(0);  Now, in
the test class, I want to test the Bar method doSomething. The
problem I've got is its use of Foo. As you can see, passing a 0
to Foo will result in a divide by zero error. I'd like to stub
out / suppress Foo.doStuff() so that this doesn't happen. All I
really need to do is ensure that doStuff() actually gets called.
So, I've done this:  @PrepareForTest({ Foo.class })
public class TestStuff  public void testOtherStuff() throws
Exception      Foo fooMock = PowerMock.createMock(Foo.class);
//suppress (method(Foo.class, "doStuff"));       Bar bar = new
Bar();   W