0

I've been trying to implement PowerMockito.Answer for awhile and still stuck.. here is the code

PowerMockito.mockStatic(testLog.class);

PowerMockito.doAnswer(new Answer<Void>() {
    public Void answer(InvocationOnMock invocation) throws Throwable {
        //Method method = invocation.getMethod();
        System.out.println("This Method got called ");
        return null;
    }
}).when(testLog.class);

//calling the testLog.log method 
testLog.log(....)

It will run just fine but without saying the println... please help....!! Regards

James

1 Answers1

0

You have not finished the expectation...

PowerMockito.doAnswer(new Answer<Void>() {
    ...
}).when(testLog.class); // << here!!

Also, testLog.class is a "Class" object - don't you really mean just "testLog"? I don't think very nice things will happen if you try and PowerMock the Class class.

BretC
  • 4,141
  • 13
  • 22