tags:

views:

246

answers:

3

Strangest thing happened my test was running ok and now its not anymore I didn't change the code at all here is the exception :

Class not found com.example.test
java.lang.ClassNotFoundException: com.example.test
    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)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
A: 

JVM is not able to find the class test. is the class name correct. I mean is it not com.example.Test?

GK
@GK it doesn't matter the package name, I use this test to test my class didn't change it at all just changed my class and tested method for this class like several times up to now, it just stopped working out of nothing
Gandalf StormCrow
Reinstalling Eclipse will help for sure:) Just backup your workspace and use it later again. Well before doing reinstall, try chburd hints.
Petar Minchev
Did you remove any references from the its buildpath. Or the resource to which the project's buildpath is referencing. If you are using eclipse then build your project once.
GK
@GK I just changed my class nothing else
Gandalf StormCrow
A: 

Check run config of the JUnit test. In the classpath tab, resotre default entries once in case that is not the case already. In project properties check if both junit package and classes source folder is in the source package and there is an actual class compilation existring for the class under test in your expected target folder.

Fazal
+1  A: 

I see that you are using Eclipse, but are you also using some other external build/test tool like Ant or Maven? Sometimes Eclipse can get out of sync when also using other external tools.

If you are using external tools, do whatever is necessary to clean up generated artifacts (e.g. mvn clean). Then refresh the Eclipse project and do a clean build as suggested previously. Then try running your unit test again using Eclipse.

Good luck and hope this helps.

cjstehno