I faced the same problem and I was able to fix it using @slomek's answeranswer but the issue resurfaced after that.
I finally fixed it by adding my project's output folder to the JUnit test's run configuration. Steps are:
- Find your project's output folder from
Project properties -> Java Build Path -> Default output folder
- Usually this is
<project-folder>/bin
- Usually this is
- Go to
Run -> Run Configurations...
- Click on the unit test's run configuration and click on the
Classpath
tab - Explicitly add your project's output folder under
User Entries
- even if the project is already included there- Click on
Advanced -> Add folder
to add the output folder
- Click on
This issue might be due to weird project setup in Eclipse - e.g. source folder with nested maven projects imported as a single project/folder (at least that was how my project was setup).