KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a class that implements InvocationHandler as below: public class MyProxyClass implements InvocationHandler { public Object invoke (Object proxy, Method method, Object[] args) throws Throwable { //Do something interesting here } } Using PowerMock & Mockito, I'm trying to pass in a mocked method object in my unit test class: @RunWith(PowerMockRunner.class) @PrepareForTest({Method.class}) public class MyProxyTest { MyProxy underTest; @Test public void testInvoke() throws Throwable { Method mockMethod = mock(Method.class); //... } } Since Method is final , I've done the @PrepareForTest trick but that doesn't seem to cut it. Is this because it's bootstrapped? Am I just going about this wrong? I've been looking at the below links but there's nothing definitive there: https://code.google.com/p/powermock/wiki/MockitoUsage13 https://code.google.com/p/powermock/wiki/MockSystem This one seems more geared toward static methods than creating a mock of a final class.
Tags (comma-separated)
Save Edits
Cancel