When I try to run some unit tests, the following error is raised:
java.lang.NoClassDefFoundError: org/junit/runner/manipulation/Filter
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
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)
I have to mention that junit-4.11.jar is added to project build path. Any ideas?
EDIT: I (Gábor Lipták) have read the other question this question supposed to be a duplicate of. This is NOT a duplicate. If someone has Gradle Buildship as build plugin in Eclipse, exactly this error is thrown, if you mistakenly put your test class in
main/resorces
instead oftest/resources
. Buildship seems to take care of test vs. compile classpath, when it comes to generate a run configuration. See the following snippets of my.classpath
file below as evidence:
<classpathentry kind="src" output="bin/main" path="src/main/resources">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/test" path="src/test/resources">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
</attributes>
</classpathentry>