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

4

1 に答える 1

0

あなたは期待を終えていません...

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

また、testLog.classは「クラス」オブジェクトです。「testLog」だけを意味していませんか? Class クラスを PowerMock しようとしても、あまりいいことが起こらないと思います。

于 2015-04-16T16:44:27.663 に答える