I am trying to run JUnit
tests from Eclipse but while running these tests, I am getting ClassNotFound
Exception
Complete Stack Trace follows:
java.lang.NoClassDefFoundError: of Caused by: java.lang.ClassNotFoundException: of at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) Exception in thread "main"
I have searched google for this and have found that couple of guys have faced this issue but none of them seems to be solving my issue. This can probably be due to difference in platforms
My development platform is as follows
OS: Windows XP
Eclipse JUNO
JUnit4
Maven2
Mean while, If I run this project using maven it runs absolutely fine.
The most strange part for me is the name of the class for which ClassNotFound
Exception is thrown. Name of the class is of
.
This is what blows me completely.
Also, what ever stack trace I have listed above, that is all what I get when I get the error nothing else.
I have been stuck in this issue for 2 days now, any help would be greatly appreciated.
When writing unit tests with JUnit, there will likely be situations when tests fail. One possibility is that our code does not meet its test criteria. That means one or more test cases fail due to assertions not being fulfilled.
I tried everything mentioned here and in other posts. Some of the solutions that people proffered were:
There were many, many more but the one that I found to work was as follows: Close the development environment. Delete the jars used by the project from my local Maven repository. Open the IDE. Build the project. Run the test.
After hours of beating my head against my keyboard and following suggested solutions, this one worked! If that doesn't work, you can try searching for the solutions I listed above.
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