JUNIT Test class in Eclipse - java.lang.ClassNotFoundException

Another possible problem is a missing builder (it will prevent from your .class file from being built).

Check that your .project file has the following lines

<buildSpec>
  <buildCommand>
    <name>org.eclipse.jdt.core.javabuilder</name>
    <arguments>
    </arguments>
  </buildCommand>
</buildSpec>
<natures>
  <nature>org.eclipse.jdt.core.javanature</nature>
</natures>

ConfigurationManagerTest is not being found on your classpath. Ensure that the ConfigurationManagerTest.class file is available on your classpath.

It might not exist if it wasn't successfully compiled or if it's being created in a directory that you haven't told the Eclipse project should be on the classpath.

Assuming that you've put your test classes in a separate folder, make sure that it shows up in the "Package Explorer" view (rather than the "Navigator" view).

Under the project properties, "Java Build Path" and the "Source" tab, you can also see if the source folder is included for building as well as where the .class files are generated.


This happened to me when I was dragging and dropping test classes to different packages. I just did the following

  1. Saved the class in a text editor.
  2. Deleted the offending class from eclipse project explorer.
  3. Re-created the class.

Bingo! I can now run the test!


There is one more possibility. I had the same problem just now and no one of the solutions here helped. Except removing and recreating of the project - I didn't want to try it. What did help, was to clean the project two times immediately one after another! Clean + build could be repeated any number of times - it won't help. Only clean+clean and after that build goes OK. (Eclipse 3.6). Of course, you should disable autobuild for that.

Edit: This post has got its last plus on 15.11.2017. So, the problem (and the solution) remains actual.