Running JUnit Tests from Eclipse gives ClassNotFound Error

I tried everything mentioned here and in other posts. Some of the solutions that people proffered were:

  1. Change the output folder for the test
  2. Create a custom builder for the project that would run test-compile from Maven
  3. Move the Maven dependencies higher in the Order and Export list in the project build path

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.


Right clicking on the project name in Eclipse and choosing "Maven --> update project" will often solve this problem.