我正在努力让PowerMockito使用我的应用程序.我已将库添加到构建路径中.我有以下测试类:
package client.controller;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@PrepareForTest(System.class)
public class SampleTest
{
@Test
public void test()
{
}
}
当我尝试运行测试时,我得到以下异常:
java.lang.NoClassDefFoundError: org/junit/internal/runners/TestClassRunner
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.powermock.modules.junit4.legacy.PowerMockRunner.301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 31 more
根据PowerMock FAQ,我应该尝试使用旧版程序包.我做了,我仍然得到同样的例外.有任何想法吗?