Problem:
Running into the following error when trying to run some Junit
tests via Run As -> JUnit Test
on Eclipse Enterprise Edition.
Class not found com.codinginformer.test.SeleniumTest
java.lang.ClassNotFoundException: com.codinginformer.test.SeleniumTest
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:766)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:490)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:513)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Solution:
This error could be due to not activating seperate output folders for each folder in your build path.
Try this potential solution and see if it works:
- Right click on your project -> Select
Properties
-> SelectJava Build Path
-> Select theSources
tab - If you don't see the
Output folder
option in the dropdown list below your build folder make sure to enable the checkboxAllow output folder for source folders
. Then double clickOutput folder
- In the following modal select
Specific output folder
. Then, enter the following output path for the enabled field:target/classes
. Note: The specific output path name doesn't matter as much as you defining an explicit output path instead of using the default output path - Select
Ok
->Apply and Close
. Finally Run the JUnit tests viaRun As -> JUnit Test
Conclusion
Thanks for reading this blog post!
If you have any questions or concerns please feel free to post a comment in this post and I will get back to you when I find the time.
If you found this article helpful please share it and make sure to follow me on Twitter and GitHub, connect with me on LinkedIn and subscribe to my YouTube channel.
Top comments (0)