我正在使用mockito-all-1.9.5-rc1.jar
和powermock-mockito-1.4.12-full.jar
。当我运行这个简单的单元测试来模拟非最终类中的最终方法时。
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@PrepareForTest(ABC.class)
public class ABCTest {
@Test
public void finalCouldBeMock() {
final ABC abc = PowerMockito.mock(ABC.class);
PowerMockito.when(abc.myMethod()).thenReturn("toto");
assertEquals("toto", abc.myMethod());
}
}
当我运行它时,我得到了
java.lang.NoClassDefFoundError: org/mockito/internal/MockitoInvocationHandler
Caused by: java.lang.ClassNotFoundException: org.mockito.internal.MockitoInvocationHandler
MockitoInvocationHandler
当我在mockito-all-1.9.5-rc1.jar
and中搜索类时powermock-mockito-1.4.12-full.jar
。我找不到任何东西。需要帮助解决这个问题!谢谢