I am getting this error when running JUnit test in Eclipse:
Class not found com.myproject.server.MyTest
java.lang.ClassNotFoundException: com.myproject.serve
-
In my case I had a wrong maven directory structure.
Which should be like:
/src/test/java/ com.myproject.server.MyTest
After I fixed that - everything worked like a charm.
讨论(0)
-
These steps worked for me.
- Delete the content of local Maven repository.
- run mvn clean install in the command line. (cd to the pom directory).
- Build Project in Eclipse.
讨论(0)
-
After having tried everything here with no improvement, I solved my issue by just restarting Eclipse
讨论(0)
-
I faced the same problem and I was able to fix it using @slomek's answer 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
- 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
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).
讨论(0)
-
I had the similar problem with my Eclipse Helios which debugging Junits. My problem was little different as i was able to run Junits successfully but when i was getting ClassNotFoundException while debugging the same JUNITs.
I have tried all sort of different solutions available in Stackoverflow.com and forums elsewhere, but nothing seem to work. After banging my head with these issue for close to two days, finally i figured out the solution to it.
If none of the solutions seem to work, just delete the .metadata folder created in your workspace. This would create an additional overhead of importing the projects and all sorts of configuration you have done, but these will surely solve these issue.
Hope these helps.
讨论(0)
-
Might be you forgotten to place the Main class and Test Case class in
/src/test/java. Check it Once.
讨论(0)
- 热议问题