I have just upgraded my SpringSource Tools Suite (STS, a variant IDE of Eclipse) to the latest version (v3.6.1). Then all my JUnit unit tests can not be run again. I am getting this error:
Class not found ClassToTest
java.lang.ClassNotFoundException: ClassToTest
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
According to this blog: ClassNotFoundException when running JUnit unit tests within Eclipse (using Maven), it is because of some misconfiguration of Maven plugin in Eclipse. However, in STS 3.6.2 I cannot find this option "Include Modules" in the Maven plugin. How can I fix this problem and re-enable my unit tests?
Right click your project in Package Explorer > click Properties go to Java Build Path > Libraries tab click on 'Add Library' button select JUnit click Next.
We can run our unit tests with Maven by using the command: mvn clean test.
There are still some back-draws on the current m2e plugin. Unit-test-cases couldn't be run as their including project grouped in a working-set. Following may help:
Try then to run your test again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With