Closed GoogleCodeExporter closed 9 years ago
I got it!
I like Mockito instead od EasyMock because the record and replay is hidden in
the framework. But the replay is triggered by the method call in when().
1. void methods are called by doAnswer().when(object).method()
2. non void static methods are called by doAnswer().when(class.method())
But my scenario of a static void method is a special case and not covered, so a
manually triggered replay is needed. I inserted a System.exit(Mockito.anyInt())
after my above code and it worked. This is the nothing calling System.exit() I
noticed before. Now the Exception is thrown.
I tried the .when(System.class, "exit", Mockito.anyInt()) but this calls the
original System.exit().
My wish is the integration of this manual method call into PowerMockito somehow
to eliminate this special behaviour of the api. Perhaps when(class) should
return a proxy on which I can call static methods are the when(class,
methodName, params) should behave like the manual call instead of invoking the
method on the original class.
Original comment by Andreas....@googlemail.com
on 10 Jun 2012 at 7:34
You need to use real partial mocking (see Mocktio docs) or stub the method
using the stubbing API.
Original comment by johan.ha...@gmail.com
on 13 Jul 2012 at 7:08
Original issue reported on code.google.com by
Andreas....@googlemail.com
on 8 Jun 2012 at 8:58