运行Junit测试类时,我面临以下错误:
我在构建路径中添加了Junit和powermock依赖项。 朱尼特-4.12 Powermock-2.0.0
如果我从添加库中明确地选择了junit并选择Junit,那么它可以工作,但是我不想那样做,因为我已经在我的build.gradle文件中添加了junit作为依赖项,并且junit jar也可以在“ Project and外部依赖性”
请让我知道我在这里想念什么?
java.lang.NoClassDefFoundError: org/junit/runner/manipulation/Filter
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadTestLoaderClass(RemoteTestRunner.java:320)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:310)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:283)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(RemoteTestRunner.java:207)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:191)
Caused by: java.lang.ClassNotFoundException: org.junit.runner.manipulation.Filter
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 8 more
我的构建文件包含junit依赖项:
def versionPowermock = "2.0.0"
dependencies {
.....
testImplementation 'junit:junit:4.12'
testCompile "org.powermock:powermock-module-junit4:${versionPowermock}"
testCompile "org.powermock:powermock-api-mockito2:${versionPowermock}"
....