我正在使用一些简单的类来查看是否可以让powermock
工作:
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@PrepareForTest(Foo.class)
public class FooTest
{
@Test
public void testFoobar(){
Foo test = PowerMock.createPartialMock(Foo.class, "foobar");
PowerMock.replay(test);
}
}
和
public class Foo
{
public String foobar(String aString){
return aString + " blah";
}
}
当我尝试运行此单元测试时,它会告诉我:
java.lang.NoClassDefFoundError: org/easymock/classextension/internal/ClassProxyFactory$MockMethodInterceptor
...
我不知道为什么要这样做。请帮忙。